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 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 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 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

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.