server: poll for new messages and update clients via WS

This commit is contained in:
2025-04-15 11:48:06 -07:00
parent 0662e6230e
commit 6f93aa4f34
10 changed files with 77 additions and 46 deletions

View File

@@ -13,8 +13,10 @@ impl ConnectionTracker {
pub fn add_peer(&mut self, socket: WebSocket, who: SocketAddr) {
warn!("adding {who:?} to connection tracker");
self.peers.insert(who, socket);
self.send_message_all(WebsocketMessage::RefreshMessages);
}
pub async fn send_message_all(&mut self, msg: WebsocketMessage) {
info!("send_message_all {msg}");
let m = serde_json::to_string(&msg).expect("failed to json encode WebsocketMessage");
let mut bad_peers = Vec::new();
for (who, socket) in &mut self.peers.iter_mut() {