This library exposes a simple WebSocket server into FXServer.
- Async
- Text messages
- Authorization header support
Convars available:
| Name | Type | Default value | Description |
|---|---|---|---|
| websocket_debug | bool | false | Defines the verbosity of logs |
| websocket_host | string | "127.0.0.1" | Defines listening host |
| websocket_port | int | 80 | Defines listening port |
| websocket_authorization | string | "" | Defines accepted Authorization header value (auth disabled if empty) |
AddEventHandler("WebSocketServer:onMessage", function(message, endpoint)
print("Received message from " .. endpoint .. ": " .. message)
end)AddEventHandler("WebSocketServer:onConnect", function(endpoint)
print("New WS remote endpoint: " .. endpoint)
end)AddEventHandler("WebSocketServer:onDisconnect", function(endpoint)
print("WS remote endpoint " .. endpoint .. " has been disconnected")
end)TriggerEvent("WebSocketServer:broadcast", "This message will be broadcasted to all connected webSocket clients.");TriggerEvent("WebSocketServer:send", "This message will be sent to a specific webSocket client.", someValidAndConnectedRemoteEndpoint);This project is licensed under the MIT License - see the LICENSE.md file for details.