Skip to main content

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

EventPurpose
x.infoProfile information exchange
x.msg.newNew text message
x.msg.updateMessage edit
x.msg.delMessage deletion

Compression

Compressed Batch Format

Messages may be compressed using Zstd when certain conditions are met.

FieldSizeDescription
Batch marker1 byte'X' (0x58)
NonEmpty list encodingvariableList of messages
Compression tag1 byte'0' = passthrough, '1' = compressed
Length prefix2 bytes (BE16)Length of following data
DatavariableRaw or Zstd-compressed bytes

Zstd Parameters

ParameterValue
DictionaryNone
Compression Level3
Max Decompressed Size65,536 bytes
Magic Bytes0x28 0xB5 0x2F 0xFD

Compression Threshold

Compression is applied when:

  • Chat version ≥ 8
  • PQ is enabled
  • Message size > 10,968 bytes