pub trait MessageHandler: Send + Sync {
// Required method
fn on_message<'life0, 'async_trait>(
&'life0 mut self,
message: Message,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn on_connected<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_disconnected<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_error<'life0, 'async_trait>(
&'life0 mut self,
error: WebSocketError,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn set_sender(&mut self, _sender: UnboundedSender<Message>) { ... }
fn send_message(&self, _message: Message) -> WebSocketResult<()> { ... }
}Expand description
Message handler trait
Required Methods§
Sourcefn on_message<'life0, 'async_trait>(
&'life0 mut self,
message: Message,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_message<'life0, 'async_trait>(
&'life0 mut self,
message: Message,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a received message
Provided Methods§
Sourcefn on_connected<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_connected<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle connection established
Sourcefn on_disconnected<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_disconnected<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle connection closed
Sourcefn on_error<'life0, 'async_trait>(
&'life0 mut self,
error: WebSocketError,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_error<'life0, 'async_trait>(
&'life0 mut self,
error: WebSocketError,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle errors
Sourcefn set_sender(&mut self, _sender: UnboundedSender<Message>)
fn set_sender(&mut self, _sender: UnboundedSender<Message>)
Set the sender for outgoing messages (optional, default implementation does nothing)
Sourcefn send_message(&self, _message: Message) -> WebSocketResult<()>
fn send_message(&self, _message: Message) -> WebSocketResult<()>
Send a message through the WebSocket (optional, default implementation returns error)