* Adds a socket to a list of room. * * @param {SocketId} id the socket id * @param {Set<Room>} rooms a set of rooms * @public
(id: SocketId, rooms: Set<Room>)
| 85 | * @public |
| 86 | */ |
| 87 | public addAll(id: SocketId, rooms: Set<Room>): Promise<void> | void { |
| 88 | if (!this.sids.has(id)) { |
| 89 | this.sids.set(id, new Set()); |
| 90 | } |
| 91 | |
| 92 | for (const room of rooms) { |
| 93 | this.sids.get(id).add(room); |
| 94 | |
| 95 | if (!this.rooms.has(room)) { |
| 96 | this.rooms.set(room, new Set()); |
| 97 | this.emit("create-room", room); |
| 98 | } |
| 99 | if (!this.rooms.get(room).has(id)) { |
| 100 | this.rooms.get(room).add(id); |
| 101 | this.emit("join-room", room, id); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Removes a socket from a room. |