WebSocketHandler

Trait WebSocketHandler 

Source
pub trait WebSocketHandler:
    Send
    + Sync
    + 'static {
    // Required method
    fn handle_connection(
        &self,
        id: ConnectionId,
        connection: Arc<WebSocketConnection>,
    ) -> impl Future<Output = ()> + Send;
}
Expand description

WebSocket handler trait for user-defined handlers

Required Methods§

Source

fn handle_connection( &self, id: ConnectionId, connection: Arc<WebSocketConnection>, ) -> impl Future<Output = ()> + Send

Handle a new WebSocket connection

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<F, Fut> WebSocketHandler for SimpleWebSocketHandler<F>
where F: Fn(ConnectionId, Arc<WebSocketConnection>) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send,