Skip to content

Commit

Permalink
refactor: revert std mem take change
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Jan 6, 2025
1 parent 5f841c3 commit d9d193d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions server/src/http/broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,23 @@ impl Broadcaster {
async fn heartbeat(&self) {
let mut active_connections = 0i64;
for mut group in self.active_connections.iter_mut() {
let clients = std::mem::take(&mut group.clients);
let ok_clients = &mut group.clients;
let mut ok_clients = Vec::new();

for ClientData { token, sender } in clients {
for ClientData { token, sender } in &group.clients {
if sender
.send(sse::Event::Comment("keep-alive".into()))
.await
.is_ok()
{
ok_clients.push(ClientData { token, sender });
ok_clients.push(ClientData {
token: token.clone(),
sender: sender.clone(),
});
}
}

active_connections += ok_clients.len() as i64;
group.clients = ok_clients;
}
CONNECTED_STREAMING_CLIENTS.set(active_connections)
}
Expand Down

0 comments on commit d9d193d

Please sign in to comment.