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

Class BroadcastOperator

packages/socket.io-postgres-emitter/lib/index.ts:248–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246]);
247
248export class BroadcastOperator<
249 EmitEvents extends EventsMap,
250 ServerSideEvents extends EventsMap,
251> implements TypedEventBroadcaster<EmitEvents>
252{
253 constructor(
254 private readonly emitter: Emitter,
255 private readonly rooms: Set<string> = new Set<string>(),
256 private readonly exceptRooms: Set<string> = new Set<string>(),
257 private readonly flags: BroadcastFlags = {},
258 ) {}
259
260 /**
261 * Targets a room when emitting.
262 *
263 * @param room
264 * @return a new BroadcastOperator instance
265 * @public
266 */
267 public to(
268 room: string | string[],
269 ): BroadcastOperator<EmitEvents, ServerSideEvents> {
270 const rooms = new Set(this.rooms);
271 if (Array.isArray(room)) {
272 room.forEach((r) => rooms.add(r));
273 } else {
274 rooms.add(room);
275 }
276 return new BroadcastOperator(
277 this.emitter,
278 rooms,
279 this.exceptRooms,
280 this.flags,
281 );
282 }
283
284 /**
285 * Targets a room when emitting.
286 *
287 * @param room
288 * @return a new BroadcastOperator instance
289 * @public
290 */
291 public in(
292 room: string | string[],
293 ): BroadcastOperator<EmitEvents, ServerSideEvents> {
294 return this.to(room);
295 }
296
297 /**
298 * Excludes a room when emitting.
299 *
300 * @param room
301 * @return a new BroadcastOperator instance
302 * @public
303 */
304 public except(
305 room: string | string[],

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…