diff options
author | Paweł Dybiec <pawel@dybiec.info> | 2022-12-25 21:35:25 +0000 |
---|---|---|
committer | Paweł Dybiec <pawel@dybiec.info> | 2022-12-25 21:35:25 +0000 |
commit | 7957ff3d8fb2c1ce9091e89cd3de6ba2f559e431 (patch) | |
tree | 27bb4b1c987090ef6bdbc64226ef962bdcd0e64f /src/main.rs | |
parent | Parse json response from server (diff) |
Support for custom message handlers
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index d4f30c4..e2a9028 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,17 @@ mod mattermost; use tokio::{self}; use tracing::{debug, info}; -#[tokio::main(worker_threads = 2)] +struct Vav{ +} +#[async_trait::async_trait] +impl mattermost::Handler for Vav{ + async fn handle(&self,message:serde_json::Value,client: & mattermost::Client) { + debug!("{message:?}"); + } +} + +#[tokio::main(worker_threads = 2)] async fn main() -> Result<(), Box<dyn std::error::Error>> { tracing_subscriber::fmt::init(); let login = std::env::var("USER_MAIL")?; @@ -12,6 +21,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { let auth = mattermost::AuthData { login, password }; let mut client = mattermost::Client::new(auth, "https://mattermost.continuum.ii.uni.wroc.pl"); client.update_bearer_token().await?; - client.handle_websocket_stream().await?; + client.handle_websocket_stream(Vav{}).await?; Ok(()) } |