* Take n bytes from the buffered Buffers * @param {number} n * @returns {Buffer}
(n)
| 18002 | const buffer = this.consume(2); |
| 18003 | __privateGet(this, _info).payloadLength = buffer.readUInt16BE(0); |
| 18004 | __privateSet(this, _state, parserStates.READ_DATA); |
| 18005 | if (!__privateMethod(this, _validatePayloadLength, validatePayloadLength_fn).call(this)) { |
| 18006 | return; |
| 18007 | } |
| 18008 | } else if (__privateGet(this, _state) === parserStates.PAYLOADLENGTH_64) { |
| 18009 | if (__privateGet(this, _byteOffset) < 8) { |
| 18010 | return callback(); |
| 18011 | } |
| 18012 | const buffer = this.consume(8); |
| 18013 | const upper = buffer.readUInt32BE(0); |
| 18014 | const lower = buffer.readUInt32BE(4); |
| 18015 | if (upper !== 0 || lower > __pow(2, 31) - 1) { |
| 18016 | failWebsocketConnection(this.ws, "Received payload length > 2^31 bytes."); |
| 18017 | return; |
| 18018 | } |
| 18019 | __privateGet(this, _info).payloadLength = lower; |
| 18020 | __privateSet(this, _state, parserStates.READ_DATA); |
| 18021 | if (!__privateMethod(this, _validatePayloadLength, validatePayloadLength_fn).call(this)) { |
| 18022 | return; |
| 18023 | } |
| 18024 | } else if (__privateGet(this, _state) === parserStates.READ_DATA) { |
| 18025 | if (__privateGet(this, _byteOffset) < __privateGet(this, _info).payloadLength) { |
| 18026 | return callback(); |
| 18027 | } |
| 18028 | const body = this.consume(__privateGet(this, _info).payloadLength); |
| 18029 | if (isControlFrame(__privateGet(this, _info).opcode)) { |
| 18030 | __privateSet(this, _loop, this.parseControlFrame(body)); |
| 18031 | __privateSet(this, _state, parserStates.INFO); |
| 18032 | } else { |
| 18033 | if (!__privateGet(this, _info).compressed) { |
| 18034 | if (!this.writeFragments(body)) { |
| 18035 | return; |
| 18036 | } |
no test coverage detected