LuaU C API to interact with websockets using IXWebSocket!
Example usage:
local socket = Socket.connect("ws://localhost:8008"); -- Connect to the socket
socket.OnMessage = function(message) -- Invoked when a message is received
print("New message from socket!", message);
socket:Send(message)
end
socket.OnClose = function() -- Invoked when the connection is closed
print("Socket Closed!");
end
socket:Send("Hello from lua"); -- Send a message
socket:Close(); -- Closes the connection
Connects to url.
local socket = Socket.connect("ws://localhost:8008");
Sends a text message to the socket.
socket
- The socket userdata returned when you connect to a socket.message
- The message you want to send
ℹ️ Callback
Optional callback invoked when a new message is received.
message
- The message received
socket.OnMessage = function(message)
print("New message from socket!", message);
end
ℹ️ Callback
Optional callback invoked when the connection is closed.
socket.OnClose = function()
print("Socket Closed!");
end