diff --git a/examples/pubsub.rs b/examples/pubsub.rs index e897e06..5897806 100644 --- a/examples/pubsub.rs +++ b/examples/pubsub.rs @@ -1,5 +1,5 @@ use std::error::Error; -use wamp_async::{Client, ClientConfig}; +use wamp_async::{Client, ClientConfig, WampDict}; #[tokio::main] async fn main() -> Result<(), Box> { @@ -44,7 +44,7 @@ async fn main() -> Result<(), Box> { println!( "Subscribing to peer.heartbeat events. Start another instance with a 'pub' argument" ); - let (sub_id, mut heartbeat_queue) = client.subscribe("peer.heartbeat").await?; + let (sub_id, mut heartbeat_queue) = client.subscribe("peer.heartbeat", WampDict::new()).await?; println!("Waiting for {} heartbeats...", max_events); while cur_event_num < max_events { diff --git a/src/client.rs b/src/client.rs index d67170c..3b5881e 100644 --- a/src/client.rs +++ b/src/client.rs @@ -397,11 +397,13 @@ impl<'a> Client<'a> { pub async fn subscribe>( &self, topic: T, + options: WampDict, ) -> Result<(WampId, SubscriptionQueue), WampError> { // Send the request let (res, result) = oneshot::channel(); if let Err(e) = self.ctl_channel.send(Request::Subscribe { uri: topic.as_ref().to_string(), + options, res, }) { return Err(From::from(format!( diff --git a/src/core/mod.rs b/src/core/mod.rs index 08660a9..d9c3fab 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -320,7 +320,7 @@ impl<'a> Core<'a> { .await } Request::Leave { res } => send::leave_realm(self, res).await, - Request::Subscribe { uri, res } => send::subscribe(self, uri, res).await, + Request::Subscribe { uri, options, res } => send::subscribe(self, uri, options, res).await, Request::Unsubscribe { sub_id, res } => send::unsubscribe(self, sub_id, res).await, Request::Publish { uri, diff --git a/src/core/send.rs b/src/core/send.rs index 6689887..e9ca742 100644 --- a/src/core/send.rs +++ b/src/core/send.rs @@ -24,6 +24,7 @@ pub enum Request<'a> { }, Subscribe { uri: WampString, + options: WampDict, res: PendingSubResult, }, Unsubscribe { @@ -187,14 +188,14 @@ pub async fn leave_realm(core: &mut Core<'_>, res: Sender> Status::Ok } -pub async fn subscribe(core: &mut Core<'_>, topic: WampString, res: PendingSubResult) -> Status { +pub async fn subscribe(core: &mut Core<'_>, topic: WampString, options: WampDict, res: PendingSubResult) -> Status { let request = core.create_request(); if let Err(e) = core .send(&Msg::Subscribe { request, topic, - options: WampDict::new(), + options, }) .await {