Skip to content

Network API

This page documents network classes and Engine connection operations. Network transport is not an ActionRegistry category and does not define invented network:* actions.

Engine integration

engine.connect(url) wires a PeerConnection to the shared Chronicle through ConsensusCore; with useWebRTC: true, it uses HybridPeerManager. The transport exchanges Automerge sync messages, not game command histories. Use engine.disconnect() before compact(), resume(), or other operations that require a detached document.

Classes

  • PeerConnection(url, engine?, options?): WebSocket client with connect(), disconnect(), sendToPeer(), broadcast(), peer IDs, and reconnect buffering.
  • HybridPeerManager(options): WebSocket/WebRTC upgrade manager with connect(), disconnect(), sendToPeer(), broadcast(), upgradeToWebRTC(peerId), and peer inspection methods.
  • WebRTCConnection(remotePeerId, config?): one encoded DataChannel with offer/answer/ICE methods, send, close, and connection state.
  • MessageCodec(config?): JSON or MessagePack encode/decode with optional compression. Encryption framing is reserved and currently unimplemented.
  • UniversalRelayServer(options?): stateless relay with start(), stop(), room routing, health endpoints, and rate limiting.
  • AuthoritativeServer(engine, options?): server-owned Engine and JSON describe/dispatch/history protocol. RoomAuthoritativeServer extends this model with room Engines.

All listed network classes are deep imports under network/; they are not re-exported by core/index.ts.