fix up the event system, no more unsafe!

This commit is contained in:
lumi 2017-05-27 16:56:44 +02:00
commit c326d5b07e
8 changed files with 110 additions and 150 deletions

View file

@ -88,11 +88,11 @@ impl ClientBuilder {
binding: PluginProxyBinding::new(dispatcher.clone()),
dispatcher: dispatcher,
};
client.dispatcher.lock().unwrap().register(Priority::Default, Box::new(move |evt: &SendElement| {
client.dispatcher.lock().unwrap().register(Priority::Default, move |evt: &SendElement| {
let mut t = transport.lock().unwrap();
t.write_element(&evt.0).unwrap();
Propagation::Continue
}));
});
client.connect(credentials)?;
client.bind()?;
Ok(client)