Mesh

interface Mesh : Seam

A Seam over a fully-connected N-peer mesh of point-to-point Connections, with support for admitting links that arrive after construction.

Obtain one from meshSeam. Beyond the Seam contract it adds addLink for dynamic peer-join.

Properties

Link copied to clipboard
abstract val incoming: Flow<Swatch>

Frames received from peers, in send order, delivered to a single collector. Cold/single-collection semantics: collect once per Seam; fan-out consumers wrap with shareIn. A second concurrent collector is unsupported and will race.

Link copied to clipboard
abstract val peers: StateFlow<Set<PeerId>>

Live set of peers currently connected. Includes selfId.

Link copied to clipboard
open val plies: StateFlow<Map<PlyId, SeamState>>

Per-ply lifecycle breakdown. Single-ply fabrics report a one-entry map keyed by PlyId.Sole. Invariant: state.value equals the rollup of plies.value.values under "any ply Woven ⇒ Woven".

Link copied to clipboard
abstract val selfId: PeerId

This peer's own identifier.

Link copied to clipboard
abstract val state: StateFlow<SeamState>

The fabric's lifecycle as observed by this peer.

Functions

Link copied to clipboard
abstract suspend fun addLink(conn: Connection)

Admit a Connection to a peer that dialed in after construction.

Link copied to clipboard
abstract suspend fun broadcast(payload: ByteArray)

Send to all other peers. Suspends until accepted by the local transport.

Link copied to clipboard
abstract suspend fun close(reason: CloseReason = CloseReason.Normal)

Disconnect from the session. Idempotent.

Link copied to clipboard
abstract suspend fun sendTo(peer: PeerId, payload: ByteArray)

Send to one peer. Suspends until accepted by the local transport.