WebSocket Server
FRM provides a WebSocket server that can be configured on a port of your choosing (Default: 8080). This is the same as the web server URL/Port.
Accessing the websocket server can be done via a browser that is using a WebSockets Tester (I recommend https://www.piesocket.com/websocket-tester). The default WebSocket connection is ws://<IP Address>:8080/
Useful Online Testers:
-
https://www.piesocket.com/websocket-tester - Ensures connection
-
https://websocketking.com/ - Allows payloads to be sent. Please note that you may have to allow Insecure connections in your browser as there is no
wssfunctionality.
The websocket server, by default, is not activated until the appropriate chat command is provided (/frm http start). You may also have the web server auto-start changing the Web_Autostart in the Config File Method to true.
Please note that the web server and web socket system are one module, so enabling one enables the other.
Subscription/Publishing:
A request is needed to be made to "subscribe" to an endpoint.
Afterwards, the mod will then "publish" the output, of the subscribed endpoints, to the connecting client as defined by the WebSocketPushCycle setting.
Each endpoint is sent as an individual message.
Response Message
Subscribing to the getPower endpoint will provide this response:
{
"endpoint": "getPower",
"data": [{
"CircuitID":0,
"PowerCapacity":9.0,
"PowerProduction":9.0,
"PowerConsumed":9.0,
"PowerMaxConsumed":9.0,
"BatteryDifferential":0.0,
"BatteryPercent":0.0,
"BatteryCapacity":0,
"BatteryTimeEmpty":"00:00:00",
"BatteryTimeFull":"00:00:00",
"FuseTriggered":false
},
{
"CircuitID":1,
"PowerCapacity":9.0,
"PowerProduction":9.0,
"PowerConsumed":9.0,
"PowerMaxConsumed":9.0,
"BatteryDifferential":0.0,
"BatteryPercent":0.0,
"BatteryCapacity":0,
"BatteryTimeEmpty":"00:00:00",
"BatteryTimeFull":"00:00:00",
"FuseTriggered":false
}],
}