Add unsubscribe command to client
This commit is contained in:
parent
20044cbea4
commit
520da02162
|
@ -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)) };
|
||||
}
|
||||
|
|
|
@ -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<()> {
|
||||
|
|
Loading…
Reference in New Issue