Performs a WebSocket upgrade to stream real-time airport state. Requires:
Upgrade: websocketairport (ICAO, 4 chars) and an API key via either:
key query parameter, orAuthorization: Bearer <API key> header
The API key is forwarded as a Bearer token to the airport’s Durable Object for auth./connect with airport and your API key.INITIAL_STATE (this confirms your role and current airport state).HEARTBEAT regularly.HEARTBEAT every 60 seconds and closes idle sessions after ~70 seconds without inbound client messages.
type is required.airport is optional on most client packets (server uses your connected airport if omitted).timestamp is optional on client packets and server-populated on outbound packets.| Packet type | Who can send | What happens |
|---|---|---|
HEARTBEAT | controller, pilot, observer | Server replies with HEARTBEAT_ACK |
GET_STATE | controller, pilot, observer | Server replies with STATE_SNAPSHOT |
STATE_UPDATE | controller only | Broadcast to same-airport clients (except sender) |
MULTI_STATE_UPDATE | controller only | Broadcast to same-airport clients (except sender) |
SHARED_STATE_UPDATE | controller only | Broadcast to same-airport clients (including sender) |
STOPBAR_CROSSING | pilot only | Broadcast to same-airport controllers |
CLOSE | controller, pilot, observer | Server closes the session gracefully |
INITIAL_STATE immediately after connectHEARTBEAT every 60 secondsHEARTBEAT_ACK in response to client HEARTBEATSTATE_SNAPSHOT in response to GET_STATESTATE_UPDATE when a controller changes one object stateMULTI_STATE_UPDATE when a controller sends a batch state changeCONTROLLER_CONNECT / CONTROLLER_DISCONNECT for controller presence changesSHARED_STATE_UPDATE when shared state changesSTOPBAR_CROSSING (controllers only) when a pilot crosses a stopbarERROR when validation/processing failsobjectId must match ^[a-zA-Z0-9_-]+$.STATE_UPDATE must include data.objectId and one of data.state or data.patch.MULTI_STATE_UPDATE must include data.updates (maximum 200 updates).SHARED_STATE_UPDATE must include data.sharedStatePatch object (maximum 10,240 serialized characters).50,000 characters.type values are rejected.