From 45166015ea8da8abc1575a22e46513c7bc9b8cc2 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 16 Dec 2024 23:40:00 +0100 Subject: [PATCH] add WsSubscribeMessage struct --- src/client.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/client.rs b/src/client.rs index dd1b65e..ea4a55e 100644 --- a/src/client.rs +++ b/src/client.rs @@ -81,6 +81,28 @@ impl Display for WsConnectMessage { } } +struct WsSubscribeMessage { + room_id: String, +} + +impl WsSubscribeMessage { + fn new(room_id: &str) -> WsSubscribeMessage { + WsSubscribeMessage { + room_id: room_id.to_string(), + } + } +} + +impl Display for WsSubscribeMessage { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + let str = format!( + "SUBSCRIBE\nid:sub-6\ndestination:/topic/{}.stream\n\n\0", + self.room_id + ); + write!(f, "{}", str) + } +} + struct WsSubscribeFeedbackMessage { room_id: String, }