Skip to content

Commit

Permalink
chore: update socket joinRoom
Browse files Browse the repository at this point in the history
  • Loading branch information
ynwd committed Oct 31, 2024
1 parent 6a5b07e commit 793d70b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/socket/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<WebSocket>();
s.add(socket);
connections.set(room, s);
} else {
connections.get(room)?.add(socket);
}
}

Expand Down

0 comments on commit 793d70b

Please sign in to comment.