()
| 778 | } |
| 779 | |
| 780 | async toBin(): Promise<Uint8Array[]> { |
| 781 | const concatenatedOriginalCommandBuffer = ByteUtils.concat(this.command.toBin()); |
| 782 | // otherwise, compress the message |
| 783 | const messageToBeCompressed = concatenatedOriginalCommandBuffer.slice(MESSAGE_HEADER_SIZE); |
| 784 | |
| 785 | // Extract information needed for OP_COMPRESSED from the uncompressed message |
| 786 | const originalCommandOpCode = readInt32LE(concatenatedOriginalCommandBuffer, 12); |
| 787 | |
| 788 | // Compress the message body |
| 789 | const compressedMessage = await compress(this.options, messageToBeCompressed); |
| 790 | // Create the msgHeader of OP_COMPRESSED |
| 791 | const msgHeader = ByteUtils.allocate(MESSAGE_HEADER_SIZE); |
| 792 | NumberUtils.setInt32LE( |
| 793 | msgHeader, |
| 794 | 0, |
| 795 | MESSAGE_HEADER_SIZE + COMPRESSION_DETAILS_SIZE + compressedMessage.length |
| 796 | ); // messageLength |
| 797 | NumberUtils.setInt32LE(msgHeader, 4, this.command.requestId); // requestID |
| 798 | NumberUtils.setInt32LE(msgHeader, 8, 0); // responseTo (zero) |
| 799 | NumberUtils.setInt32LE(msgHeader, 12, OP_COMPRESSED); // opCode |
| 800 | // Create the compression details of OP_COMPRESSED |
| 801 | const compressionDetails = ByteUtils.allocate(COMPRESSION_DETAILS_SIZE); |
| 802 | NumberUtils.setInt32LE(compressionDetails, 0, originalCommandOpCode); // originalOpcode |
| 803 | NumberUtils.setInt32LE(compressionDetails, 4, messageToBeCompressed.length); // Size of the uncompressed compressedMessage, excluding the MsgHeader |
| 804 | compressionDetails[8] = Compressor[this.options.agreedCompressor]; // compressorID |
| 805 | return [msgHeader, compressionDetails, compressedMessage]; |
| 806 | } |
| 807 | } |
nothing calls this directly
no test coverage detected