Expand description
WebSocket upgrade handler and message multiplexer for the /ws endpoint.
On upgrade, the handler either reuses an existing Session (when the
client supplies ?session_id=N) or creates a new one, and greets the client
with a session.connected notification. From then on the socket carries
JSON-RPC 2.0 requests from the client, and their responses and the job
notifications back. Each request is queued into the session’s background
thread in the order it arrived, and its response is sent back with the
request’s id so the client can correlate them.
Graceful disconnect (session.disconnect) tears the session down
immediately and flushes telemetry. Hard disconnects (socket close without
that request) leave the session in a 5-minute grace period so the client
can reconnect with the same session_id and pick up where it left off.
Structs§
- WsQuery
Params - Query parameters for WebSocket connection.
Enums§
- Outgoing 🔒
- A message for the client.
Functions§
- handle_
api_ 🔒request - Sends a request to the session’s background thread, and its response to the client when it’s done.
- handle_
socket 🔒 - Function to handle a WebSocket connection.
- ws_
handler 🔒 - WebSocket handler to upgrade the connection and handle messages.