Skip to main content

ws_handler

Function ws_handler 

Source
pub(crate) async fn ws_handler(
    __arg0: State<Arc<SessionManager>>,
    __arg1: Query<WsQueryParams>,
    headers: HeaderMap,
    ws: WebSocketUpgrade,
) -> Response
Expand description

WebSocket handler to upgrade the connection and handle messages.

Accepts an optional session_id query parameter to reconnect to an existing session. Example: ws://localhost:45127/ws?session_id=123

Rejects connections from browser pages of other origins: browsers don’t apply CORS to WebSockets, so any page could otherwise drive the server.