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