(packet: Packet, data: RawData)
| 31 | } |
| 32 | |
| 33 | doWrite(packet: Packet, data: RawData) { |
| 34 | const opts: { compress?: boolean } = {}; |
| 35 | if (packet.options) { |
| 36 | opts.compress = packet.options.compress; |
| 37 | } |
| 38 | |
| 39 | if (this.opts.perMessageDeflate) { |
| 40 | const len = |
| 41 | // @ts-ignore |
| 42 | "string" === typeof data ? Buffer.byteLength(data) : data.length; |
| 43 | if (len < this.opts.perMessageDeflate.threshold) { |
| 44 | opts.compress = false; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | this.ws.send(data, opts); |
| 49 | } |
| 50 | } |