Skip to content

Commit 65e7fe4

Browse files
committed
fix topic key for user events
1 parent 029ad46 commit 65e7fe4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ws/robust/subs.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::super::ws_manager::{Message, SubscriptionSendData};
1+
use super::super::ws_manager::{Message, Subscription, SubscriptionSendData};
22
use super::{Stream, Sub, SubId, SubToken, Subs, Unsubscribe};
33
use crate::BaseUrl;
44
use anyhow::Result;
@@ -24,6 +24,14 @@ impl Drop for SubToken {
2424
}
2525

2626
impl Subs {
27+
fn get_topic_key_for_subscription(topic: &Topic) -> String {
28+
match topic {
29+
Subscription::UserEvents { user: _ } => "userEvents".to_string(),
30+
Subscription::OrderUpdates { user: _ } => "orderUpdates".to_string(),
31+
_ => serde_json::to_string(topic).expect("Failed to convert subscription to string"),
32+
}
33+
}
34+
2735
pub async fn connect(
2836
base_url: &BaseUrl,
2937
mut cancel_rx: mpsc::Receiver<()>,
@@ -75,7 +83,7 @@ impl Subs {
7583
.id_counter
7684
.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
7785

78-
let topic_key = serde_json::to_string(&topic)?;
86+
let topic_key = Self::get_topic_key_for_subscription(&topic);
7987

8088
let sub = Sub {
8189
id,

0 commit comments

Comments
 (0)