(opts: BroadcastOptions, callback: (socket) => void)
| 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(); |
no test coverage detected