From 9763cdf0de67083b51ffbd05ee477df6b7ff3ba9 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Sun, 22 Feb 2026 16:35:20 -0800 Subject: [PATCH] Throttle view count updates --- server.ts | 19 ++++++++++++------- todo.md | 7 ++++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/server.ts b/server.ts index 7182dbe..6a4f9fe 100644 --- a/server.ts +++ b/server.ts @@ -243,14 +243,19 @@ function broadcast() { } } +let viewerCountTimer: ReturnType | null = null; function broadcastViewerCount() { - const msg = JSON.stringify({ - type: "viewerCount", - viewerCount: clients.size, - }); - for (const ws of clients) { - ws.send(msg); - } + if (viewerCountTimer) return; + viewerCountTimer = setTimeout(() => { + viewerCountTimer = null; + const msg = JSON.stringify({ + type: "viewerCount", + viewerCount: clients.size, + }); + for (const ws of clients) { + ws.send(msg); + } + }, 1000); } function getAdminSnapshot() { diff --git a/todo.md b/todo.md index cd4162f..03a07da 100644 --- a/todo.md +++ b/todo.md @@ -2,4 +2,9 @@ - [ ] Win streaks - [ ] Experiment with more models -- [ ] Actual admin page where I enter a passkey, get a jwt and can see status, pause/resume, see costs etc + +## TODO Bugfixes + +- [ ] Text wrapping on long single-strings +- [ ] Stream crashing on fresh deployment (because the ffmpeg pipe dies, we should handle this in the ffmpeg script) +- [ ] Throttle view count updates