diff options
Diffstat (limited to 'docs/net/websocket.md')
| -rw-r--r-- | docs/net/websocket.md | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/docs/net/websocket.md b/docs/net/websocket.md new file mode 100644 index 0000000..5a82a70 --- /dev/null +++ b/docs/net/websocket.md @@ -0,0 +1,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 |
