parent
2811c490a0
commit
e3e48148f0
|
@ -78,7 +78,7 @@ async fn login_and_sync(
|
||||||
println!("logged in as {}", username);
|
println!("logged in as {}", username);
|
||||||
|
|
||||||
client
|
client
|
||||||
.add_event_emitter(Box::new(AutoJoinBot::new(client.clone())))
|
.set_event_emitter(Box::new(AutoJoinBot::new(client.clone())))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
client.sync(SyncSettings::default()).await;
|
client.sync(SyncSettings::default()).await;
|
||||||
|
|
|
@ -88,7 +88,7 @@ async fn login_and_sync(
|
||||||
// add our CommandBot to be notified of incoming messages, we do this after the initial
|
// add our CommandBot to be notified of incoming messages, we do this after the initial
|
||||||
// sync to avoid responding to messages before the bot was running.
|
// sync to avoid responding to messages before the bot was running.
|
||||||
client
|
client
|
||||||
.add_event_emitter(Box::new(CommandBot::new(client.clone())))
|
.set_event_emitter(Box::new(CommandBot::new(client.clone())))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// since we called `sync_once` before we entered our sync loop we must pass
|
// since we called `sync_once` before we entered our sync loop we must pass
|
||||||
|
|
|
@ -86,7 +86,7 @@ async fn login_and_sync(
|
||||||
|
|
||||||
client.sync_once(SyncSettings::default()).await.unwrap();
|
client.sync_once(SyncSettings::default()).await.unwrap();
|
||||||
client
|
client
|
||||||
.add_event_emitter(Box::new(ImageBot::new(client.clone(), image)))
|
.set_event_emitter(Box::new(ImageBot::new(client.clone(), image)))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let settings = SyncSettings::default().token(client.sync_token().await.unwrap());
|
let settings = SyncSettings::default().token(client.sync_token().await.unwrap());
|
||||||
|
|
|
@ -44,7 +44,7 @@ async fn login(
|
||||||
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");
|
||||||
let client = Client::new(homeserver_url).unwrap();
|
let client = Client::new(homeserver_url).unwrap();
|
||||||
|
|
||||||
client.add_event_emitter(Box::new(EventCallback)).await;
|
client.set_event_emitter(Box::new(EventCallback)).await;
|
||||||
|
|
||||||
client
|
client
|
||||||
.login(username, password, None, Some("rust-sdk"))
|
.login(username, password, None, Some("rust-sdk"))
|
||||||
|
|
|
@ -556,8 +556,8 @@ impl Client {
|
||||||
/// Add `EventEmitter` to `Client`.
|
/// Add `EventEmitter` to `Client`.
|
||||||
///
|
///
|
||||||
/// The methods of `EventEmitter` are called when the respective `RoomEvents` occur.
|
/// The methods of `EventEmitter` are called when the respective `RoomEvents` occur.
|
||||||
pub async fn add_event_emitter(&self, emitter: Box<dyn EventEmitter>) {
|
pub async fn set_event_emitter(&self, emitter: Box<dyn EventEmitter>) {
|
||||||
self.base_client.add_event_emitter(emitter).await;
|
self.base_client.set_event_emitter(emitter).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the joined rooms this client knows about.
|
/// Returns the joined rooms this client knows about.
|
||||||
|
|
|
@ -430,7 +430,7 @@ impl BaseClient {
|
||||||
/// Add `EventEmitter` to `Client`.
|
/// Add `EventEmitter` to `Client`.
|
||||||
///
|
///
|
||||||
/// The methods of `EventEmitter` are called when the respective `RoomEvents` occur.
|
/// The methods of `EventEmitter` are called when the respective `RoomEvents` occur.
|
||||||
pub async fn add_event_emitter(&self, emitter: Box<dyn EventEmitter>) {
|
pub async fn set_event_emitter(&self, emitter: Box<dyn EventEmitter>) {
|
||||||
let emitter = Emitter {
|
let emitter = Emitter {
|
||||||
inner: emitter,
|
inner: emitter,
|
||||||
store: self.store.clone(),
|
store: self.store.clone(),
|
||||||
|
|
|
@ -746,7 +746,7 @@ mod test {
|
||||||
let emitter = Box::new(EvEmitterTest(vec));
|
let emitter = Box::new(EvEmitterTest(vec));
|
||||||
|
|
||||||
let client = get_client().await;
|
let client = get_client().await;
|
||||||
client.add_event_emitter(emitter).await;
|
client.set_event_emitter(emitter).await;
|
||||||
|
|
||||||
let response = sync_response(SyncResponseFile::Default);
|
let response = sync_response(SyncResponseFile::Default);
|
||||||
client.receive_sync_response(response).await.unwrap();
|
client.receive_sync_response(response).await.unwrap();
|
||||||
|
@ -778,7 +778,7 @@ mod test {
|
||||||
let emitter = Box::new(EvEmitterTest(vec));
|
let emitter = Box::new(EvEmitterTest(vec));
|
||||||
|
|
||||||
let client = get_client().await;
|
let client = get_client().await;
|
||||||
client.add_event_emitter(emitter).await;
|
client.set_event_emitter(emitter).await;
|
||||||
|
|
||||||
let response = sync_response(SyncResponseFile::Invite);
|
let response = sync_response(SyncResponseFile::Invite);
|
||||||
client.receive_sync_response(response).await.unwrap();
|
client.receive_sync_response(response).await.unwrap();
|
||||||
|
@ -801,7 +801,7 @@ mod test {
|
||||||
let emitter = Box::new(EvEmitterTest(vec));
|
let emitter = Box::new(EvEmitterTest(vec));
|
||||||
|
|
||||||
let client = get_client().await;
|
let client = get_client().await;
|
||||||
client.add_event_emitter(emitter).await;
|
client.set_event_emitter(emitter).await;
|
||||||
|
|
||||||
let response = sync_response(SyncResponseFile::Leave);
|
let response = sync_response(SyncResponseFile::Leave);
|
||||||
client.receive_sync_response(response).await.unwrap();
|
client.receive_sync_response(response).await.unwrap();
|
||||||
|
@ -831,7 +831,7 @@ mod test {
|
||||||
let emitter = Box::new(EvEmitterTest(vec));
|
let emitter = Box::new(EvEmitterTest(vec));
|
||||||
|
|
||||||
let client = get_client().await;
|
let client = get_client().await;
|
||||||
client.add_event_emitter(emitter).await;
|
client.set_event_emitter(emitter).await;
|
||||||
|
|
||||||
let response = sync_response(SyncResponseFile::All);
|
let response = sync_response(SyncResponseFile::All);
|
||||||
client.receive_sync_response(response).await.unwrap();
|
client.receive_sync_response(response).await.unwrap();
|
||||||
|
@ -856,7 +856,7 @@ mod test {
|
||||||
let emitter = Box::new(EvEmitterTest(vec));
|
let emitter = Box::new(EvEmitterTest(vec));
|
||||||
|
|
||||||
let client = get_client().await;
|
let client = get_client().await;
|
||||||
client.add_event_emitter(emitter).await;
|
client.set_event_emitter(emitter).await;
|
||||||
|
|
||||||
let response = sync_response(SyncResponseFile::Voip);
|
let response = sync_response(SyncResponseFile::Voip);
|
||||||
client.receive_sync_response(response).await.unwrap();
|
client.receive_sync_response(response).await.unwrap();
|
||||||
|
|
Loading…
Reference in New Issue