* Broadcasts a packet. * * Options: * - `flags` {Object} flags for this packet * - `except` {Array} sids that should be excluded * - `rooms` {Array} list of rooms to broadcast to * * @param {Object} packet the packet object * @param {Object} opts the options * @pu
(packet: any, opts: BroadcastOptions)
| 160 | * @public |
| 161 | */ |
| 162 | public broadcast(packet: any, opts: BroadcastOptions): void { |
| 163 | const flags = opts.flags || {}; |
| 164 | const packetOpts = { |
| 165 | preEncoded: true, |
| 166 | volatile: flags.volatile, |
| 167 | compress: flags.compress, |
| 168 | }; |
| 169 | |
| 170 | packet.nsp = this.nsp.name; |
| 171 | const encodedPackets = this._encode(packet, packetOpts); |
| 172 | |
| 173 | this.apply(opts, (socket) => { |
| 174 | if (typeof socket.notifyOutgoingListeners === "function") { |
| 175 | socket.notifyOutgoingListeners(packet); |
| 176 | } |
| 177 | |
| 178 | socket.client.writeToEngine(encodedPackets, packetOpts); |
| 179 | }); |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Broadcasts a packet and expects multiple acknowledgements. |
no test coverage detected