base_client: Consume sync responses and store the sync token.

master
Damir Jelić 2019-11-24 22:40:52 +01:00
parent 3ab37ee8bd
commit 4daea54a33
2 changed files with 10 additions and 0 deletions

View File

@ -255,6 +255,8 @@ impl AsyncClient {
// cb(room.clone(), Arc::new(event.clone())).await; // cb(room.clone(), Arc::new(event.clone())).await;
// } // }
} }
client.receive_sync_response(&response);
} }
Ok(response) Ok(response)
@ -323,4 +325,8 @@ impl AsyncClient {
let response = self.send(request).await?; let response = self.send(request).await?;
Ok(response) Ok(response)
} }
pub fn sync_token(&self) -> Option<String> {
self.base_client.read().unwrap().sync_token.clone()
}
} }

View File

@ -232,4 +232,8 @@ impl Client {
let mut room = self.get_or_create_room(room_id).write().unwrap(); let mut room = self.get_or_create_room(room_id).write().unwrap();
room.receive_state_event(event) room.receive_state_event(event)
} }
pub fn receive_sync_response(&mut self, response: &api::sync::sync_events::Response) {
self.sync_token = Some(response.next_batch.clone());
}
} }