You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,23 @@ require("gwsockets")
37
37
GWSockets.addVerifyPath( "/etc/ssl/certs" )
38
38
```
39
39
40
+
* If you would like to enable the `permessage-deflate` extension which allows you to send and receive compressed messages, you can enable it with the following functions:
41
+
42
+
```LUA
43
+
-- Do note this will only be enabled if the websocket server supports permessage-deflate and enables it during handshake.
44
+
WEBSOCKET:setMessageCompression(true)
45
+
```
46
+
47
+
* You can also disable context takeover during compression, which will prevent re-using the same compression context over multiple messages.
48
+
This will decrease the memory usage at the cost of a worse compression ratio.
49
+
50
+
```LUA
51
+
WEBSOCKET:setDisableContextTakeover(true)
52
+
```
53
+
54
+
*WARNING:* Enabling compression over encrypted connections (`WSS://`) may make you vulnerable to [CRIME](https://en.wikipedia.org/wiki/CRIME)/[BREACH](https://en.wikipedia.org/wiki/BREACH) attacks.
55
+
Make sure you know what you are doing, or avoid sending sensitive information over websocket messages.
56
+
40
57
* Next add any cookies or headers you would like to send with the initial request (Optional)
41
58
42
59
```LUA
@@ -67,9 +84,13 @@ require("gwsockets")
67
84
* Lastly open the connection
68
85
69
86
```LUA
70
-
WEBSOCKET:open()
87
+
WEBSOCKET:open(shouldClearQueue=true)
71
88
```
72
89
90
+
*NOTE:* By default, opening a connection will clear the queued messages. This is due to the fact there
91
+
is no way of knowing what's in the queue, and what has been received by the remote. If you would like to
92
+
disable this, you may use `open(false)`.
93
+
73
94
* Once the socket has been opened you can send messages using the `write` function
0 commit comments