BETA | 1.9.6c - Burkino/SynapseX GitHub Wiki
SX (new) WebSocket API documenation:
A common request I get is to add a WebSocket API - here you go.
As of right now, the WebSocket API does not support WSS websockets (i'm too lazy to add yet another SSL library to SX, sorry)
Example script:
local WebSocket = syn.websocket.connect("ws://localhost:123/test") -- Specify your WebSocket URL here.
WebSocket.OnMessage:Connect(function(Msg)
print(Msg) -- Print messages sent to SX.
end)
local Ctr = 1
while wait(1) do
WebSocket:Send("gamer vision " .. tostring(Ctr)) -- Send messages to the WebSocket server.
WebSocket:Send("epic gamer vision " .. tostring(Ctr))
WebSocket:Send("epicer gamer vision " .. tostring(Ctr))
Ctr = Ctr + 1
if Ctr == 150 then
WebSocket:Close() -- Close the websocket when you are done! (this is done implicitly on teleports aswell)
do return end
end
end
WebSocket syn.websocket.connect(string url)
- Connects to the url
specified. Errors if the connection fails.
WebSocket:Send(string Message)
- Sends Message
to the server.
WebSocket:Close()
- Closes the connection with the server.
Event WebSocket.OnMessage
- Event is fired when a message is sent from the server.
Event WebSocket.OnClose
- Event is fired when the WebSocket is closed (either by WebSocket:Close or by the server)