Skip to content

WebSocket Messages

WebSocket handlers are implemented in server/src/routes/ws.ts.

Endpoint: same host/port as HTTP, commonly ws://<host>:<port>/ws.

Authentication: the server requires a valid JWT on the WebSocket handshake, passed as the query parameter token (for example ws://localhost:3000/ws?token=<jwt>). The browser WebSocket API cannot set Authorization headers; the web client appends this query parameter automatically from the stored login token. Unauthenticated upgrade attempts receive HTTP 403.

Authorization: after authentication, subscription handlers enforce access (for example track requires an allowed beacon for non-admin users; overview, debug, gatify, gateway_config, test_beacon, and debug_device require an admin JWT).

Client message types

TypePurposeTopic behavior
trackSubscribe to position updates for one beacon MACsubscribes track-{mac}
debugSubscribe to debug tracking stream for one beacon MACsubscribes track-debug-{mac}
overviewSubscribe to map-level overview updatessubscribes overview-{map_id}
eventsSubscribe to global event streamsubscribes events
test_beaconSend a test beacon message for processingsubscribes test-beacon and forwards message
gatifySubscribe to gatify streamsubscribes gatify
debug_deviceDevice debug channel controlaction-based subscribe/unsubscribe/keepalive

debug_device actions

debug_device messages include:

  • action: "subscribe" -> subscribes debug-device-{search}
  • action: "unsubscribe" -> unsubscribes debug-device-{search}
  • action: "keepalive" -> refreshes keepalive for the tracked search key

Validation

Incoming messages are validated by schema before subscription logic:

  • HttpWsMessageTrackSchema
  • HttpWsMessageOverviewSchema
  • HttpWsMessageDebugDeviceSchema