(packets: Packet[])
| 43 | } |
| 44 | |
| 45 | send(packets: Packet[]) { |
| 46 | this.writable = false; |
| 47 | |
| 48 | for (let i = 0; i < packets.length; i++) { |
| 49 | const packet = packets[i]; |
| 50 | const isLast = i + 1 === packets.length; |
| 51 | |
| 52 | if (this._canSendPreEncodedFrame(packet)) { |
| 53 | // the WebSocket frame was computed with WebSocket.Sender.frame() |
| 54 | // see https://github.com/websockets/ws/issues/617#issuecomment-283002469 |
| 55 | // @ts-expect-error use of untyped member |
| 56 | this.socket._sender.sendFrame( |
| 57 | packet.options.wsPreEncodedFrame, |
| 58 | isLast ? this._onSentLast : this._onSent, |
| 59 | ); |
| 60 | } else { |
| 61 | this.parser.encodePacket( |
| 62 | packet, |
| 63 | this.supportsBinary, |
| 64 | isLast ? this._doSendLast : this._doSend, |
| 65 | ); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Whether the encoding of the WebSocket frame can be skipped. |
no test coverage detected