pub trait WsHandler: Send + Sync {
// Required method
fn on_message<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut WsContext,
msg: WsMessage,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn on_connect<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 mut WsContext,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 mut WsContext,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn handles_path(&self, _path: &str) -> bool { ... }
}Expand description
Trait for WebSocket message handlers
Required Methods§
Sourcefn on_message<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut WsContext,
msg: WsMessage,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_message<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut WsContext,
msg: WsMessage,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a message is received
Provided Methods§
Sourcefn on_connect<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 mut WsContext,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_connect<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 mut WsContext,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a new WebSocket connection is established
Sourcefn on_disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 mut WsContext,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 mut WsContext,
) -> Pin<Box<dyn Future<Output = HandlerResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when the connection is closed
Sourcefn handles_path(&self, _path: &str) -> bool
fn handles_path(&self, _path: &str) -> bool
Check if this handler should handle the given path