spawn handler futures on the reactor

This commit is contained in:
Daniel Griffen 2019-01-09 20:18:38 -08:00
parent 885e96a495
commit 971a386ca0
No known key found for this signature in database
GPG key ID: 315FB75FAC745B68

View file

@ -141,8 +141,11 @@ impl IrcReactor {
&mut self, client: IrcClient, mut handler: F &mut self, client: IrcClient, mut handler: F
) where F: FnMut(&IrcClient, Message) -> U + 'static, ) where F: FnMut(&IrcClient, Message) -> U + 'static,
U: IntoFuture<Item = (), Error = error::IrcError> + 'static { U: IntoFuture<Item = (), Error = error::IrcError> + 'static {
let handle = self.inner.handle().clone();
self.handlers.push(Box::new(client.stream().for_each(move |message| { self.handlers.push(Box::new(client.stream().for_each(move |message| {
handler(&client, message) handle.spawn(handler(&client, message).into_future().map_err(|_| (())));
Ok(())
}))); })));
} }