writeCompressedPacket writes a compressed packet with header. data should start with 7 size space for header followed by payload.
(data []byte, uncompressedLen int)
| 195 | // writeCompressedPacket writes a compressed packet with header. |
| 196 | // data should start with 7 size space for header followed by payload. |
| 197 | func (c *compIO) writeCompressedPacket(data []byte, uncompressedLen int) (int, error) { |
| 198 | mc := c.mc |
| 199 | comprLength := len(data) - 7 |
| 200 | if debug { |
| 201 | fmt.Printf( |
| 202 | "writeCompressedPacket: comprLength=%v, uncompressedLen=%v, seq=%v\n", |
| 203 | comprLength, uncompressedLen, mc.compressSequence) |
| 204 | } |
| 205 | |
| 206 | // compression header |
| 207 | putUint24(data[0:3], comprLength) |
| 208 | data[3] = mc.compressSequence |
| 209 | putUint24(data[4:7], uncompressedLen) |
| 210 | |
| 211 | mc.compressSequence++ |
| 212 | return mc.writeWithTimeout(data) |
| 213 | } |
no test coverage detected