diff --git a/src/http/server.rs b/src/http/server.rs index 3915f3c..e6be763 100644 --- a/src/http/server.rs +++ b/src/http/server.rs @@ -1041,11 +1041,11 @@ impl HttpServer { /// Push a WebSocket message to all channels on a given path. pub fn ws_push_all_channels(&self, path: &str, message_type: WsMessageType, blob: KiBlob) { - if let Some(channels) = self.ws_channels.get(path) { - channels.iter().for_each(|channel_id| { - send_ws_push(*channel_id, message_type, blob.clone()); - }); - } + ws_push_all_channels(self.ws_channels, path, message_type, blob); + } + + pub fn get_ws_channels(&self) -> HashMap> { + self.ws_channels.clone() } } @@ -1079,6 +1079,19 @@ pub fn send_ws_push(channel_id: u32, message_type: WsMessageType, blob: KiBlob) .unwrap() } +pub fn ws_push_all_channels( + ws_channels: HashMap>, + path: &str, + message_type: WsMessageType, + blob: KiBlob, +) { + if let Some(channels) = ws_channels.get(path) { + channels.iter().for_each(|channel_id| { + send_ws_push(*channel_id, message_type, blob.clone()); + }); + } +} + /// Guess the MIME type of a file from its extension. pub fn get_mime_type(filename: &str) -> String { let file_path = std::path::Path::new(filename);