Web Sockets

WebSocket.connect

<WebSocketConnection> WebSocket.connect(<string> url)

Establishes a WebSocket connection to the specified URL.

local ws = WebSocket.connect("ws://localhost:8080")

ws.OnMessage:Connect(function(message)
	print(message)
end)

ws.OnClose:Connect(function()
	print("Closed")
end)

ws:Send("Hello, World!")

WebSocketConnection

ws = WebSocket.connect(url)

Methods

Method
Description
Send(<string> message)

Sends a message over the WebSocket connection

Close()

Closes the WebSocket connection

Events

Event
Description
OnMessage(<string> message)

Fired when a message is received over the WebSocket connection

OnClose()

Fired when the WebSocket connection is closed


Last updated