WebSocket
WebSocket clients and the primitives behind the WebSocket helper.
Opens a WebSocket and returns a socket object with modern lowercase aliases and legacy names.
local ws = WebSocket.connect("wss://echo.websocket.events")
ws.OnMessage:Connect(function(message)
print(message)
end)
ws:Send("hello")
Legacy low-level WebSocket helpers that operate on a connection id.
local id = websocket_connect("wss://echo.websocket.events")
websocket_send(id, "hello")
for _, message in ipairs(websocket_poll(id)) do
print(message)
end
websocket_close(id)
Sends a message through the socket.
local ws = WebSocket.open("wss://echo.websocket.events")
ws:Send("hello")
Closes the socket.
local ws = WebSocket.open("wss://echo.websocket.events")
ws:Close()
Signals fired for incoming messages and connection close.
local ws = WebSocket.open("wss://echo.websocket.events")
ws.OnMessage:Connect(function(message)
print(message)
end)
ws.OnClose:Connect(function()
print("closed")
end)
True once the socket has closed.
local ws = WebSocket.open("wss://echo.websocket.events")
print(ws.IsClosed)