* Excludes a room when emitting. * * @example * // the "foo" event will be broadcast to all connected clients, except the ones that are in the "room-101" room * io.except("room-101").emit("foo", "bar"); * * // with an array of rooms * io.except(["room-101", "room-102"]).emit("fo
(room: Room | Room[])
| 91 | * @return a new {@link BroadcastOperator} instance for chaining |
| 92 | */ |
| 93 | public except(room: Room | Room[]) { |
| 94 | const exceptRooms = new Set(this.exceptRooms); |
| 95 | if (Array.isArray(room)) { |
| 96 | room.forEach((r) => exceptRooms.add(r)); |
| 97 | } else { |
| 98 | exceptRooms.add(room); |
| 99 | } |
| 100 | return new BroadcastOperator<EmitEvents, SocketData>( |
| 101 | this.adapter, |
| 102 | this.rooms, |
| 103 | exceptRooms, |
| 104 | this.flags, |
| 105 | ); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Sets the compress flag. |