|
| 1 | +use chrono::serde::ts_milliseconds_option; |
| 2 | +use chrono::{DateTime, Utc}; |
1 | 3 | use clap::Parser;
|
2 | 4 | use futures_util::{SinkExt, StreamExt};
|
| 5 | +use serde::{Deserialize, Serialize}; |
3 | 6 | use tokio_tungstenite::{connect_async, tungstenite::protocol::Message};
|
4 | 7 | use webex::{self};
|
5 | 8 |
|
| 9 | +#[allow(dead_code)] |
| 10 | +#[derive(Deserialize, Default, Debug)] |
| 11 | +#[serde(rename_all = "camelCase")] |
| 12 | +pub struct Event { |
| 13 | + pub id: Option<String>, |
| 14 | + //pub data: Option<String>, |
| 15 | + pub filter_message: Option<bool>, |
| 16 | + //pub headers: Option<String>, |
| 17 | + pub sequence_number: Option<u32>, |
| 18 | + #[serde(with = "ts_milliseconds_option")] |
| 19 | + pub timestamp: Option<DateTime<Utc>>, |
| 20 | + pub tracking_id: Option<String>, |
| 21 | +} |
| 22 | + |
6 | 23 | #[derive(Parser, Debug)]
|
7 | 24 | #[command(author, version, about, long_about = None)]
|
8 | 25 | struct Args {
|
@@ -60,7 +77,12 @@ async fn main() {
|
60 | 77 | Message::Ping(data) => {
|
61 | 78 | let _ = ws_stream.send(Message::Pong(data)).await;
|
62 | 79 | }
|
63 |
| - Message::Binary(_) => println!("{}", message), |
| 80 | + Message::Binary(data) => { |
| 81 | + let e = serde_json::from_str::<Event>( |
| 82 | + &String::from_utf8(data).expect("Error decoding UT8"), |
| 83 | + ); |
| 84 | + println!("{:#?}", e); |
| 85 | + } |
64 | 86 | _ => (),
|
65 | 87 | }
|
66 | 88 | }
|
|
0 commit comments