Skip to content

Commit ee16fe0

Browse files
committed
http: add workaround for ws_push_all_channels within HttpServer::handle_request
1 parent adcd0e3 commit ee16fe0

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/http/server.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,11 +1041,11 @@ impl HttpServer {
10411041

10421042
/// Push a WebSocket message to all channels on a given path.
10431043
pub fn ws_push_all_channels(&self, path: &str, message_type: WsMessageType, blob: KiBlob) {
1044-
if let Some(channels) = self.ws_channels.get(path) {
1045-
channels.iter().for_each(|channel_id| {
1046-
send_ws_push(*channel_id, message_type, blob.clone());
1047-
});
1048-
}
1044+
ws_push_all_channels(self.ws_channels, path, message_type, blob);
1045+
}
1046+
1047+
pub fn get_ws_channels(&self) -> HashMap<String, HashSet<u32>> {
1048+
self.ws_channels.clone()
10491049
}
10501050
}
10511051

@@ -1079,6 +1079,19 @@ pub fn send_ws_push(channel_id: u32, message_type: WsMessageType, blob: KiBlob)
10791079
.unwrap()
10801080
}
10811081

1082+
pub fn ws_push_all_channels(
1083+
ws_channels: HashMap<String, HashSet<u32>>,
1084+
path: &str,
1085+
message_type: WsMessageType,
1086+
blob: KiBlob,
1087+
) {
1088+
if let Some(channels) = ws_channels.get(path) {
1089+
channels.iter().for_each(|channel_id| {
1090+
send_ws_push(*channel_id, message_type, blob.clone());
1091+
});
1092+
}
1093+
}
1094+
10821095
/// Guess the MIME type of a file from its extension.
10831096
pub fn get_mime_type(filename: &str) -> String {
10841097
let file_path = std::path::Path::new(filename);

0 commit comments

Comments
 (0)