Skip to content

Commit

Permalink
http: add workaround for ws_push_all_channels within HttpServer::hand…
Browse files Browse the repository at this point in the history
…le_request
  • Loading branch information
nick1udwig committed Nov 14, 2024
1 parent adcd0e3 commit ee16fe0
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, HashSet<u32>> {
self.ws_channels.clone()
}
}

Expand Down Expand Up @@ -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<String, HashSet<u32>>,
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);
Expand Down

0 comments on commit ee16fe0

Please sign in to comment.