WebSocketHandler

Trait WebSocketHandler 

Source
pub trait WebSocketHandler: Send + Sync {
    // Required method
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        req: Request,
        websocket: WebSocketConnection,
    ) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Available on crate feature websocket only.
Expand description

Core WebSocket handler trait that receives both request context and WebSocket connection.

This trait is implemented automatically for functions that match the signature requirements through the UniversalWebSocketHandler trait.

§Implementation Note

You typically don’t implement this trait directly. Instead, use the UniversalWebSocketHandler trait which provides automatic conversion.

Required Methods§

Source

fn handle<'life0, 'async_trait>( &'life0 self, req: Request, websocket: WebSocketConnection, ) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle a WebSocket connection with full request context.

§Parameters
  • req - The HTTP request that initiated the WebSocket upgrade
  • websocket - The established WebSocket connection
§Returns

A Response indicating the result of the WebSocket session

Implementors§