Add unsubscribe command to client

This commit is contained in:
Patrick Auernig 2018-04-06 13:29:01 +02:00
parent 20044cbea4
commit 520da02162
2 changed files with 9 additions and 0 deletions

View File

@ -36,5 +36,8 @@ fn main() {
drpc.subscribe(Event::ActivityJoinRequest, |s| s)
.expect("Failed to subscribe to event");
drpc.unsubscribe(Event::ActivityJoinRequest, |j| j)
.expect("Failed to unsubscribe from event");
loop { thread::sleep(time::Duration::from_secs(10)) };
}

View File

@ -64,6 +64,12 @@ impl<T> Client<T>
self.execute(Command::Subscribe, f(SubscriptionArgs::new()), Some(evt))
}
pub fn unsubscribe<F>(&mut self, evt: Event, f: F) -> Result<Payload<Subscription>>
where F: FnOnce(SubscriptionArgs) -> SubscriptionArgs
{
self.execute(Command::Unsubscribe, f(SubscriptionArgs::new()), Some(evt))
}
// private
fn handshake(&mut self) -> Result<()> {