Expand description
WebSocket routes for the Wactorz server.
Two routes are mounted under the same axum Router:
-
/ws— Python-compatible aggregated-state bridge. Compatible withmonitor.html(and any client expectingfull_snapshot/patch/delete_agentJSON messages). -
/mqtt— Transparent WebSocket proxy to the Mosquitto broker’s WS listener (configurable host/port, defaultlocalhost:9001). Compatible withmqtt.js/frontend/dist/index.html.
Together these two routes ensure any combination of
python|rust backend × monitor.html|frontend/dist/index.html frontend
works without any client-side changes.
§/ws message protocol (mirrors monitor_server.py)
Server → browser on connect:
{ "type": "full_snapshot", "state": { "agents": [...], "nodes": [...], ... } }Server → browser on MQTT event:
{ "type": "patch", "event": { ... }, "state": { ... } }Server → browser after delete command:
{ "type": "delete_agent", "agent_id": "...", "state": { ... } }Browser → server (commands):
{ "type": "command", "command": "pause|stop|resume|delete", "agent_id": "..." }Structs§
- Bridge
State - Monitor
State - Mirrors the in-memory state maintained by Python’s
monitor_server.py. - WsBridge
- WsEnvelope
- Raw MQTT message forwarded from the broker event loop.
Consumed by
WsBridge::spawn_monitor_task; not sent to browser clients.