Skip to content

WebSocket transport

PeerConnection provides the baseline transport. A connection receives a relay-assigned peer ID, emits net:ready, and routes application messages as { type: "p2p", targetPeerId, payload }. The receiver removes the transport wrapper and emits the flat payload through net:message, adding the local transport's fromPeerId.

MessageCodec defaults to MessagePack with compression for payloads above its threshold. JSON is available as a compatibility format. Binary frames use a flags byte followed by the payload; the compressed bit is implemented.

The encrypted bit is reserved. MessageCodec throws if it receives that bit; general codec/network encryption is not wired. The standalone E2EEncryption implementation is exercised by the Cuttle example/tests, but is not imported into the general peer or server paths.