(packets: Packet[])
| 219 | } |
| 220 | |
| 221 | send(packets: Packet[]) { |
| 222 | this.writable = false; |
| 223 | |
| 224 | if (this.shouldClose) { |
| 225 | debug("appending close packet to payload"); |
| 226 | packets.push({ type: "close" }); |
| 227 | this.shouldClose(); |
| 228 | this.shouldClose = null; |
| 229 | } |
| 230 | |
| 231 | const doWrite = (data: string) => { |
| 232 | const compress = packets.some((packet) => { |
| 233 | return packet.options && packet.options.compress; |
| 234 | }); |
| 235 | this.write(data, { compress }); |
| 236 | }; |
| 237 | |
| 238 | if (this.protocol === 3) { |
| 239 | (this.parser as typeof parser_v3).encodePayload( |
| 240 | packets, |
| 241 | this.supportsBinary, |
| 242 | doWrite, |
| 243 | ); |
| 244 | } else { |
| 245 | (this.parser as typeof parser_v4).encodePayload(packets, doWrite); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Writes data as response to poll request. |
no test coverage detected