Trait mattermost_api::socket::WebsocketHandler [−][src]
pub trait WebsocketHandler: Send + Sync {
fn callback<'life0, 'async_trait>(
&'life0 self,
_message: WebsocketEvent
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait,
{ ... }
}
Expand description
Handler trait for receiving websocket messages.
Implement on a struct you create, and pass to
connect_to_websocket
to connect to your
Mattermost instance’s websocket API.
Example
use async_trait::async_trait;
use mattermost_api::prelude::*;
struct Handler {}
#[async_trait]
impl WebsocketHandler for Handler {
async fn callback(&self, message: WebsocketEvent) {
println!("{:?}", message);
}
}