Session expiration stuff isnt just limited to what i was doing with calls apparently
This commit is contained in:
parent
6c5298cdc8
commit
21f31b086f
2 changed files with 11 additions and 16 deletions
|
@ -10,7 +10,7 @@ edition = "2018"
|
||||||
#ruma-client-api = {git = "https://github.com/ruma/ruma"}
|
#ruma-client-api = {git = "https://github.com/ruma/ruma"}
|
||||||
#ruma-events = {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-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-macros = { git = "https://github.com/matrix-org/matrix-rust-sdk" }
|
||||||
matrix-sdk-common = { git = "https://github.com/matrix-org/matrix-rust-sdk" }
|
matrix-sdk-common = { git = "https://github.com/matrix-org/matrix-rust-sdk" }
|
||||||
|
|
25
src/main.rs
25
src/main.rs
|
@ -116,6 +116,7 @@ async fn handle_call_candidates(client: &Client, room_id: &RoomId, call_id: Stri
|
||||||
impl EventEmitter for CommandBot {
|
impl EventEmitter for CommandBot {
|
||||||
async fn on_room_message(&self, room: SyncRoom, event: &SyncMessageEvent<MessageEventContent>) {
|
async fn on_room_message(&self, room: SyncRoom, event: &SyncMessageEvent<MessageEventContent>) {
|
||||||
if let SyncRoom::Joined(room) = room {
|
if let SyncRoom::Joined(room) = room {
|
||||||
|
println!("Syncroom joined: {:?}", room);
|
||||||
if let SyncMessageEvent {
|
if let SyncMessageEvent {
|
||||||
content: MessageEventContent::Text(TextMessageEventContent { body: msg_body, .. }),
|
content: MessageEventContent::Text(TextMessageEventContent { body: msg_body, .. }),
|
||||||
sender,
|
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");
|
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
|
// 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()));
|
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)
|
.add_event_emitter(commandbot)
|
||||||
.await;
|
.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
|
// since we called sync before we `sync_forever` we must pass that sync token to
|
||||||
// `sync_forever`
|
// `sync_forever`
|
||||||
let settings = SyncSettings::default().token(client.sync_token().await.unwrap());
|
let settings = SyncSettings::default().token(client.sync_token().await.unwrap());
|
||||||
// this keeps state from the server streaming in to CommandBot via the EventEmitter trait
|
// this keeps state from the server streaming in to CommandBot via the EventEmitter trait
|
||||||
client.sync_forever(settings, async move |response| {
|
client.sync_forever(settings, |_| async {
|
||||||
let client = &client_ref;
|
/* 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 {
|
for (room_id, room) in response.rooms.join {
|
||||||
|
println!("room: {:?}", room_id);
|
||||||
for rawevent in &room.timeline.events {
|
for rawevent in &room.timeline.events {
|
||||||
let event = rawevent.deserialize().unwrap();
|
let event = rawevent.deserialize().unwrap();
|
||||||
|
|
||||||
|
@ -220,16 +225,6 @@ async fn login_and_sync(homeserver_url: String, username: String, password: Stri
|
||||||
let user_server = sender.server_name();
|
let user_server = sender.server_name();
|
||||||
println!("Content: {:?}", call_id);
|
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;
|
handle_call_invite(client, &room_id, call_id, user_id.to_string(), user_server.to_string(), offer).await;
|
||||||
},
|
},
|
||||||
CallHangup(e) => {},
|
CallHangup(e) => {},
|
||||||
|
@ -243,7 +238,7 @@ async fn login_and_sync(homeserver_url: String, username: String, password: Stri
|
||||||
println!("Got unknown event type here: {:?}", event);
|
println!("Got unknown event type here: {:?}", event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}).await;
|
}).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Reference in a new issue