diff --git a/src/ws/robust/subs.rs b/src/ws/robust/subs.rs index 4fed97b..b499818 100644 --- a/src/ws/robust/subs.rs +++ b/src/ws/robust/subs.rs @@ -1,4 +1,4 @@ -use super::super::ws_manager::{Message, SubscriptionSendData}; +use super::super::ws_manager::{Message, Subscription, SubscriptionSendData}; use super::{Stream, Sub, SubId, SubToken, Subs, Unsubscribe}; use crate::BaseUrl; use anyhow::Result; @@ -24,6 +24,14 @@ impl Drop for SubToken { } impl Subs { + fn get_topic_key_for_subscription(topic: &Topic) -> String { + match topic { + Subscription::UserEvents { user: _ } => "userEvents".to_string(), + Subscription::OrderUpdates { user: _ } => "orderUpdates".to_string(), + _ => serde_json::to_string(topic).expect("Failed to convert subscription to string"), + } + } + pub async fn connect( base_url: &BaseUrl, mut cancel_rx: mpsc::Receiver<()>, @@ -75,7 +83,7 @@ impl Subs { .id_counter .fetch_add(1, std::sync::atomic::Ordering::SeqCst); - let topic_key = serde_json::to_string(&topic)?; + let topic_key = Self::get_topic_key_for_subscription(&topic); let sub = Sub { id,