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§
Sourcefn 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_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,
连接建立时调用
Sourcefn 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_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,
收到消息时调用
Sourcefn 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,
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,
连接关闭时调用