Compression
Each message between a third party client and Broadcast servers has to be compressed using Zlib Library. Zlib is industry standard compression library available for any platform. Header Packet of Five character needs to prefix with all Compress Message.
🔒 How to encode the Message:
-
First form message to be send over socket as mentioned in section 4.3.
-
Compress above message formed using zlib library and append 6 bytes at start with firs byte value = 5, next 5 byte will length of the compress message. E.g.,
| Header | Message |
|---|---|
| 500073 | Compressed Dat |
🔓 How to decode the Message:
-
The first bytes of the broadcast packet indicate the whether message is compressed or not. If first byte contain 5(♣) then message is compressed message and if it contain 2(☻) then it is uncompressed message.
-
Next 5 byte indicate the length of message.
-
In case of multiple message, Each message contain header and non-compressed message.
| Header | Message |
|---|---|
| 500073 | Compressed Data |
⬇️
| Header1 | Message1 | Header2 | Message2 |
|---|---|---|---|
| 200253 | Uncompressed data | 200278 | Uncompressed data |