Expand description
Tier 1 presence — the serverless P2P mesh (presence-topology-v0.1 §3).
For small gatherings, presence needs no dedicated server: peers connect directly and each sends its pose to the others. The only shared infrastructure is a stateless rendezvous used once, at join, to introduce peers — it never sees poses and holds no session state, so if every server on earth is gone, two people who can reach each other still share presence. That’s the survivability floor of the whole design.
This module is the transport-agnostic core: MeshCoordinator manages the peer
set, fans out the local pose, and feeds received peer poses into
PresenceState — exactly what a browser needs, with the actual byte transport
(MeshTransport) left to a binding. The real binding is WebRTC data channels;
tests use an in-memory loopback, so the mesh logic is verified with no network.
Signal is the rendezvous wire (SDP/ICE introduction), defined here so a
rendezvous service — or another peer — can implement it.
Structs§
- Mesh
Coordinator - The socket-free P2P mesh coordinator: peer-set management + pose fan-out +
feeding received poses into
PresenceState. Tier-1 presence, no server. - Mesh
Pose - A pose on the mesh wire — the same shape as a presence-wire pose, but
sender-stamped: with no server clock, the sender fills
tsfrom its own monotonic clock and receivers interpolate against that sender’s timeline.
Enums§
- Mesh
Event - A peer connection lifecycle event surfaced by the transport.
- Signal
- Rendezvous signaling — the messages peers exchange (via a stateless rendezvous)
to introduce themselves and negotiate a direct connection. The rendezvous relays
these blindly; it never handles a
MeshPose.
Constants§
- MAX_
MESH_ PEERS - Max peers in a mesh before a world should upgrade to a relay (topology §3): a full mesh is O(n²) in connections, so past this it’s cheaper to run a Tier-2 relay.
Traits§
- Mesh
Transport - The transport seam: how the coordinator actually moves bytes between peers. The real implementation is WebRTC data channels (a feature-gated binding); tests use an in-memory loopback. Keeping this a trait is what makes the mesh logic testable with no network and swappable across transports.
Functions§
- should_
offer - Perfect-negotiation tiebreak: the lower peer id creates the offer. This avoids “glare” — both sides offering at once — without any central coordinator, so two peers introduced by the rendezvous deterministically agree who initiates.
Type Aliases§
- PeerId
- A peer’s occupant id within a mesh (assigned at the rendezvous).