Skip to main content

ws_handler

Function ws_handler 

Source
pub async fn ws_handler<T>(socket: WebSocket, hub: WsHub<T>)
where T: Clone + Send + Serialize + DeserializeOwned + 'static,
Expand description

One connected WebSocket. Spawn from your axum handler:

ws.on_upgrade(move |socket| ws_handler(socket, hub.clone()))

The future runs until the client disconnects, the keepalive ping fails, or the broadcast channel is exhausted.