Skip to main content

Module server_websocket

Module server_websocket 

Source
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§

WsQueryParams
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.