Skip to main content

Module envelope

Module envelope 

Source
Expand description

Message envelope for reliable delivery and synchronization.

Every message between client and server is wrapped in an envelope that provides:

  • Sequence numbers for ordering and acknowledgment
  • Timestamps for clock synchronization
  • Piggyback acknowledgments to reduce round trips

§Wire Format

The envelope is optional for backward compatibility. Messages can be sent either as raw payloads (legacy) or wrapped in envelopes (new protocol).

// Legacy format (still supported)
{ "type": "heartbeat" }

// Envelope format
{
  "seq": 42,
  "ack": 41,
  "ts": 1701234567890,
  "payload": { "type": "heartbeat" }
}

Structs§

Envelope
Message envelope wrapping any payload with delivery metadata.

Enums§

MaybeEnveloped
Either an enveloped message or a raw payload (for backward compatibility).