Skip to main content

ClientHandler

Trait ClientHandler 

Source
pub trait ClientHandler: Send + Sync {
    // Required methods
    fn on_connect<'life0, 'life1, 'async_trait>(
        &'life0 self,
        connection: &'life1 Connection,
    ) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn on_message<'life0, 'life1, 'async_trait>(
        &'life0 self,
        connection: &'life1 Connection,
        message: Message,
    ) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn on_disconnect<'life0, 'life1, 'async_trait>(
        &'life0 self,
        connection: &'life1 Connection,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

客户端处理器 trait

Required Methods§

Source

fn on_connect<'life0, 'life1, 'async_trait>( &'life0 self, connection: &'life1 Connection, ) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

连接建立时调用

Source

fn on_message<'life0, 'life1, 'async_trait>( &'life0 self, connection: &'life1 Connection, message: Message, ) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

收到消息时调用

Source

fn on_disconnect<'life0, 'life1, 'async_trait>( &'life0 self, connection: &'life1 Connection, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

连接关闭时调用

Implementors§