Fix off-by-one in first presence message

This commit is contained in:
arne 2024-01-27 13:32:34 +01:00
commit df03793047

View file

@ -23,12 +23,12 @@ const server = Bun.serve<WebsocketData>({
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(<Message>{
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)
}
},