Trait WebsocketHandler

Source
pub trait WebsocketHandler: Send + Sync {
    // Provided method
    fn callback<'life0, 'async_trait>(
        &'life0 self,
        _message: WebsocketEvent,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: '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);
    }
}

Provided Methods§

Source

fn callback<'life0, 'async_trait>( &'life0 self, _message: WebsocketEvent, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Function to implement to receive websocket messages.

Implementors§