(packets)
| 89 | } |
| 90 | |
| 91 | override write(packets) { |
| 92 | this.writable = false; |
| 93 | |
| 94 | // encodePacket efficient as it uses WS framing |
| 95 | // no need for encodePayload |
| 96 | for (let i = 0; i < packets.length; i++) { |
| 97 | const packet = packets[i]; |
| 98 | const lastPacket = i === packets.length - 1; |
| 99 | |
| 100 | encodePacket(packet, this.supportsBinary, (data) => { |
| 101 | // Sometimes the websocket has already been closed but the browser didn't |
| 102 | // have a chance of informing us about it yet, in that case send will |
| 103 | // throw an error |
| 104 | try { |
| 105 | this.doWrite(packet, data); |
| 106 | } catch (e) { |
| 107 | debug("websocket closed before onclose event"); |
| 108 | } |
| 109 | |
| 110 | if (lastPacket) { |
| 111 | // fake drain |
| 112 | // defer to next tick to allow Socket to clear writeBuffer |
| 113 | nextTick(() => { |
| 114 | this.writable = true; |
| 115 | this.emitReserved("drain"); |
| 116 | }, this.setTimeoutFn); |
| 117 | } |
| 118 | }); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | abstract doWrite(packet: Packet, data: RawData); |
| 123 |
nothing calls this directly
no test coverage detected