diff --git a/Cargo.toml b/Cargo.toml index bd7c66c..c90f912 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" #ruma-client-api = {git = "https://github.com/ruma/ruma"} #ruma-events = {git = "https://github.com/ruma/ruma"} -matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk" } +matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk", features = ["encryption"] } matrix-sdk-base = { git = "https://github.com/matrix-org/matrix-rust-sdk" } matrix-sdk-common-macros = { git = "https://github.com/matrix-org/matrix-rust-sdk" } matrix-sdk-common = { git = "https://github.com/matrix-org/matrix-rust-sdk" } diff --git a/src/main.rs b/src/main.rs index 5db111d..8664277 100644 --- a/src/main.rs +++ b/src/main.rs @@ -116,6 +116,7 @@ async fn handle_call_candidates(client: &Client, room_id: &RoomId, call_id: Stri impl EventEmitter for CommandBot { async fn on_room_message(&self, room: SyncRoom, event: &SyncMessageEvent) { if let SyncRoom::Joined(room) = room { + println!("Syncroom joined: {:?}", room); if let SyncMessageEvent { content: MessageEventContent::Text(TextMessageEventContent { body: msg_body, .. }), sender, @@ -171,7 +172,7 @@ async fn login_and_sync(homeserver_url: String, username: String, password: Stri let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL"); // create a new Client with the given homeserver url and config - let mut client = Client::new_with_config(homeserver_url, client_config).unwrap(); + let mut client = Client::new(homeserver_url).unwrap(); let commandbot = Box::new(CommandBot::new(client.clone())); @@ -196,16 +197,20 @@ async fn login_and_sync(homeserver_url: String, username: String, password: Stri .add_event_emitter(commandbot) .await; - let client_ref = &client; +// let client_ref = &client.clone(); // since we called sync before we `sync_forever` we must pass that sync token to // `sync_forever` let settings = SyncSettings::default().token(client.sync_token().await.unwrap()); // this keeps state from the server streaming in to CommandBot via the EventEmitter trait - client.sync_forever(settings, async move |response| { - let client = &client_ref; + client.sync_forever(settings, |_| async { +/* let client = &client_ref; + println!("Response, full: {:?}", response); +// client.sync_token().await.unwrap(); + //client.sync(settings).await.unwrap(); // sync the client? for (room_id, room) in response.rooms.join { + println!("room: {:?}", room_id); for rawevent in &room.timeline.events { let event = rawevent.deserialize().unwrap(); @@ -219,16 +224,6 @@ async fn login_and_sync(homeserver_url: String, username: String, password: Stri let user_id = sender.localpart(); let user_server = sender.server_name(); println!("Content: {:?}", call_id); - - - let message = MessageEventContent::Text(TextMessageEventContent { - body: "🎉🎊🥳 let's PARTY!! 🥳🎊🎉".to_string(), - formatted: None, - relates_to: None, - }); - - client.room_send(&room_id, message, None).await.unwrap(); - handle_call_invite(client, &room_id, call_id, user_id.to_string(), user_server.to_string(), offer).await; }, @@ -243,7 +238,7 @@ async fn login_and_sync(homeserver_url: String, username: String, password: Stri println!("Got unknown event type here: {:?}", event); } } - } + }*/ }).await; Ok(())