diff --git a/modules/socket/mod.ts b/modules/socket/mod.ts index c5856e00..8e71d8cb 100644 --- a/modules/socket/mod.ts +++ b/modules/socket/mod.ts @@ -41,12 +41,13 @@ export default function socketModule(s: Fastro) { } function joinRoom(ctx: Context, socket: WebSocket, room: string) { - if (!connections.has(room)) { + const s = connections.get(room); + if (s) { + s.add(socket); + } else { const s = new Set(); s.add(socket); connections.set(room, s); - } else { - connections.get(room)?.add(socket); } }