Message Types and Compression
Draft
This section is under construction.
ChatMessage Format
Chat messages are JSON-encoded with the following structure:
{
"v": "1",
"event": "x.msg.new",
"params": { ... }
}
Common Event Types
| Event | Purpose |
|---|---|
x.info | Profile information exchange |
x.msg.new | New text message |
x.msg.update | Message edit |
x.msg.del | Message deletion |
Compression
Compressed Batch Format
Messages may be compressed using Zstd when certain conditions are met.
| Field | Size | Description |
|---|---|---|
| Batch marker | 1 byte | 'X' (0x58) |
| NonEmpty list encoding | variable | List of messages |
| Compression tag | 1 byte | '0' = passthrough, '1' = compressed |
| Length prefix | 2 bytes (BE16) | Length of following data |
| Data | variable | Raw or Zstd-compressed bytes |
Zstd Parameters
| Parameter | Value |
|---|---|
| Dictionary | None |
| Compression Level | 3 |
| Max Decompressed Size | 65,536 bytes |
| Magic Bytes | 0x28 0xB5 0x2F 0xFD |
Compression Threshold
Compression is applied when:
- Chat version ≥ 8
- PQ is enabled
- Message size > 10,968 bytes