MCPcopy
hub / github.com/socketio/socket.io / addAll

Method addAll

packages/socket.io-adapter/lib/in-memory-adapter.ts:87–104  ·  view source on GitHub ↗

* 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>)

Source from the content-addressed store, hash-verified

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.

Callers 2

index.tsFile · 0.80
joinMethod · 0.80

Calls 2

emitMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected