blob: 5a82a70ef3d99ef29dec6a1d6b7606946166f975 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
## ws
net.wss(url)
net.ws(url)**
both function identically, wss just uses openssl over socket
will call each other when the url protocol mismatches the function
can return an error
```lua
net.wss("amyy.cc") -- connects to wss://amyy.cc
net.wss("ws://amyy.cc") -- identical to net.wss("amyy.cc"
```
```lua
local con = new.ws("amyy.cc")
while true do
local frame = con:read()
print(frame.content)
end
```
### con:read
con:read()
reads the oldest unread frame from the server or wait for the next frame
can return an error
return table has the frame content (.content) and opcode (.opcode)
### con:write
con:write(content)
sends a frame, returns nil or an error
### con:close
con:close()
calls __gc early
|