pub trait WebSocketHandlerwhere
    Arc<Self>: Sync,
{ type Context: Send + Sync; fn connect<'life0, 'async_trait>(
        self: &'life0 Arc<Self>,
        peer: SocketAddr
    ) -> Pin<Box<dyn Future<Output = Result<Self::Context>> + Send + 'async_trait>>
   where
        'life0: 'async_trait,
        Self: 'async_trait
; fn message<'life0, 'life1, 'life2, 'async_trait>(
        self: &'life0 Arc<Self>,
        ctx: &'life1 Self::Context,
        msg: Message,
        sink: &'life2 UnboundedSender<Message>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
   where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
; fn with_handshake(self: &Arc<Self>) -> bool { ... } fn with_timeout(self: &Arc<Self>) -> Duration { ... } fn disconnect<'life0, 'async_trait>(
        self: &'life0 Arc<Self>,
        _ctx: Self::Context,
        _result: Result<()>
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
   where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... } fn handshake<'life0, 'life1, 'life2, 'async_trait>(
        self: &'life0 Arc<Self>,
        _ctx: &'life1 Self::Context,
        _msg: Message,
        _sink: &'life2 UnboundedSender<Message>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
   where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: Sync + 'async_trait
, { ... } }
Expand description

WebSocketHandler trait that represents the WebSocket processor functionality. This trait is supplied to the WebSocket which subsequently invokes it’s functions during websocket connection and messages. The trait can override with_handshake() method to enable invocation of the handshake() method upon receipt of the first valid websocket message from the incoming connection.

Required Associated Types

Context type used by impl trait to represent websocket connection

Required Methods

Called immediately when connection is established This function can return an error to terminate the connection

Called for every websocket message This function can return an error to terminate the connection

Provided Methods

Enables optional invocation of the handshake method with the first message received form the incoming websocket

Sets the default connection timeout if no messages have been received

Called upon websocket disconnection

Called upon receipt of the first websocket message if with_handshake() returns true This function can return an error to terminate the connection

Implementors