1
0
forked from brl/citadel-tools

Emit event when creating a new realm

This commit is contained in:
Bruce Leidl 2021-11-29 16:15:31 -05:00
parent 220920cb2f
commit 160fc47494
2 changed files with 10 additions and 2 deletions

View File

@ -59,7 +59,7 @@ impl Inner {
self.manager = Arc::downgrade(manager);
}
pub fn add_handler<F>(&mut self, handler: F)
fn add_handler<F>(&mut self, handler: F)
where F: Fn(&RealmEvent),
F: 'static + Send + Sync
{
@ -109,6 +109,12 @@ impl RealmEventListener {
self.running.swap(val, Ordering::SeqCst)
}
pub fn send_event(&self, event: RealmEvent) {
if self.is_running() {
self.inner().send_event(event);
}
}
pub fn add_handler<F>(&self, handler: F)
where F: Fn(&RealmEvent),
F: 'static + Send + Sync

View File

@ -356,7 +356,9 @@ impl RealmManager {
}
pub fn new_realm(&self, name: &str) -> Result<Realm> {
self.inner_mut().realms.create_realm(name)
let realm = self.inner_mut().realms.create_realm(name)?;
self.inner().events.send_event(RealmEvent::New(realm.clone()));
Ok(realm)
}
pub fn delete_realm(&self, realm: &Realm, save_home: bool) -> Result<()> {