Room

interface Room

A membership-aware session room built over a us.tractat.kuilt.core.Seam.

The key abstraction above us.tractat.kuilt.core.Seam: peers become Members only after completing the admit/identify handshake. Raw connected-but-unidentified peers are invisible to consumers of Room — they do not appear in roster and their frames are dropped from incoming.

All flows are coroutine-scope-bound (the us.tractat.kuilt.core.Loom backing this room's us.tractat.kuilt.core.Seam drives the lifecycle). Call leave to clean up.

Properties

Link copied to clipboard
abstract val attestedPrincipals: StateFlow<Map<PeerId, Principal>>

Host-verified principals of currently-linked peers, keyed by the PeerId each was verified against at admission — the roster analogue of the per-member Member.principal.

Link copied to clipboard
abstract val events: Flow<MembershipEvent>

Stream of MembershipEvents describing roster and liveness changes.

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

Stream of RoomFrames received from admitted members.

Link copied to clipboard
abstract val localFabric: StateFlow<FabricAvailability>

Whether this peer's own end of the fabric carrying this room can carry frames now.

Link copied to clipboard
open val maxPayloadBytes: Int?

The largest bytes a single broadcast or sendTo may carry, or null when this room cannot tell.

Link copied to clipboard
abstract val resumeToken: ResumeToken?

The joiner's reconnect credential, available after the admit handshake completes.

Link copied to clipboard
abstract val role: StateFlow<SessionRole>

The role this peer plays in the room.

Link copied to clipboard
abstract val roomId: StateFlow<RoomId?>

Which room this is — the identity every member of one session agrees on, or null while this peer does not know it yet.

Link copied to clipboard
abstract val roster: StateFlow<Set<Member>>

The live set of admitted members. Does NOT include this peer itself.

Link copied to clipboard
abstract val selfId: PeerId

This peer's own identifier (mirrors us.tractat.kuilt.core.Seam.selfId).

Functions

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

Broadcast bytes to all other admitted members.

Link copied to clipboard
abstract fun channel(id: String): Seam

Returns a Seam view scoped to this channel id.

Link copied to clipboard
abstract suspend fun leave(reason: LeaveReason = LeaveReason.Normal)

Leave the room cleanly. Idempotent.

Link copied to clipboard
abstract suspend fun resume(token: ResumeToken): ResumeResult.JoinerOutcome

Attempt to resume this room from a ResumeToken after a transport drop.

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

Send bytes to one specific admitted member.