aboutsummaryrefslogtreecommitdiff
path: root/docs/net/websocket.md
diff options
context:
space:
mode:
authorame <[email protected]>2025-06-13 20:31:24 -0500
committerame <[email protected]>2025-06-13 20:31:24 -0500
commit2efda12fcae7869bc3cc8782dbcaceae65d251f8 (patch)
tree9f380005409549d69eb0b6cf1f2a661dbb38c03d /docs/net/websocket.md
parentc6714b7212548a55de8ed9e22f4b416f312358b0 (diff)
clean net code and made net docs better
Diffstat (limited to 'docs/net/websocket.md')
-rw-r--r--docs/net/websocket.md46
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