Skip to content

Commit

Permalink
server: fix live logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pnmadelaine committed Oct 10, 2023
1 parent 74bf88c commit 9707f75
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions typhon/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ pub mod live {
if !state.contains_key(&id) {
state.insert(id.clone(), (vec![], Vec::new()));
}
let (lines, listeners) = state.get_mut(&id).unwrap();
let (lines, ref mut listeners) = state.get_mut(&id).unwrap();
lines.push(line.clone());

for i in 0..listeners.len() {
if let Err(_) = listeners[i].send(line.clone()).await {
listeners.remove(i);
let mut new_listeners: Listeners = Vec::new();
for listener in listeners.drain(..) {
match listener.send(line.clone()).await {
Ok(()) => new_listeners.push(listener),
Err(_) => (),
}
}
*listeners = new_listeners;
}
Message::Listen {
id,
Expand Down

0 comments on commit 9707f75

Please sign in to comment.