From df037930477acda9e88ae1cb460e9431c3604ab6 Mon Sep 17 00:00:00 2001 From: arne Date: Sat, 27 Jan 2024 13:32:34 +0100 Subject: [PATCH] Fix off-by-one in first presence message --- server/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/index.ts b/server/index.ts index aadcb4f..e5e8b35 100644 --- a/server/index.ts +++ b/server/index.ts @@ -23,12 +23,12 @@ const server = Bun.serve({ open(ws) { // register newly connected client and tell them how many other people are there console.log('Connection opened', ws.data.clientId) - clients.set(ws.data.clientId, ws) const enterNotice = JSON.stringify({ type: 'presence-information', others: clients.size, }) - for (const [uuid, client] of clients.entries()) { + clients.set(ws.data.clientId, ws) + for (const client of clients.values()) { client.send(enterNotice, true) } },