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

Method apply

packages/socket.io-adapter/lib/in-memory-adapter.ts:333–358  ·  packages/socket.io-adapter/lib/in-memory-adapter.ts::Adapter.apply
(opts: BroadcastOptions, callback: (socket) => void)

Source from the content-addressed store, hash-verified

331 }
332
333 private apply(opts: BroadcastOptions, callback: (socket) => void): void {
334 const rooms = opts.rooms;
335 const except = this.computeExceptSids(opts.except);
336
337 if (rooms.size) {
338 const ids = new Set();
339 for (const room of rooms) {
340 if (!this.rooms.has(room)) continue;
341
342 for (const id of this.rooms.get(room)) {
343 if (ids.has(id) || except.has(id)) continue;
344 const socket = this.nsp.sockets.get(id);
345 if (socket) {
346 callback(socket);
347 ids.add(id);
348 }
349 }
350 }
351 } else {
352 for (const [id] of this.sids) {
353 if (except.has(id)) continue;
354 const socket = this.nsp.sockets.get(id);
355 if (socket) callback(socket);
356 }
357 }
358 }
359
360 private computeExceptSids(exceptRooms?: Set<Room>) {
361 const exceptSids = new Set();

Callers 15

broadcastMethod · 0.95
broadcastWithAckMethod · 0.95
socketsMethod · 0.95
fetchSocketsMethod · 0.95
addSocketsMethod · 0.95
delSocketsMethod · 0.95
disconnectSocketsMethod · 0.95
onFunction · 0.80
index.jsFile · 0.80
onFunction · 0.80
index.jsFile · 0.80
server.jsFile · 0.80

Calls 3

computeExceptSidsMethod · 0.95
callbackFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected