LoomRoomHost

class LoomRoomHost(loom: Loom, pattern: Pattern, clock: () -> Instant = { Clock.System.now() }, heartbeatConfig: HeartbeatConfig = HeartbeatConfig()) : RoomHost

Transport-agnostic single-room RoomHost over any Loom. Opens one host session via SeamRoomFactory.host, hands the live Room to onRoom exactly once, then suspends until cancelled (leaving the room cleanly on the way out).

Constructed with an us.tractat.kuilt.core.InMemoryLoom it is the in-memory host double for admit-handshake tests: pair it with a SeamRoomFactory.join over the same loom and the Hello → Welcome → onPeer exchange runs entirely under virtual time, no socket bound.

The fabric-specific hosts delegate their session lifecycle here; only the multi-connection accept loop (Ktor) and platform cleanup live in those adapters.

Parameters

loom

the Loom to host over.

pattern

the session Pattern (session name) to advertise.

clock

time source for partition detection; defaults to wall-clock kotlin.time.Clock.System. Inject a virtual clock in tests.

heartbeatConfig

partition-detection timing.

Constructors

Link copied to clipboard
constructor(loom: Loom, pattern: Pattern, clock: () -> Instant = { Clock.System.now() }, heartbeatConfig: HeartbeatConfig = HeartbeatConfig())

Functions

Link copied to clipboard
open override fun close()

No-op. Lifecycle is owned by the calling kotlinx.coroutines.CoroutineScope: cancelling the scope tears start down via structured concurrency. The loom is the caller's to close.

Link copied to clipboard
open suspend override fun start(onRoom: suspend (Room) -> Unit)

Begin hosting. Each admitted connection is surfaced to onRoom as a live Room. Suspends until the calling kotlinx.coroutines.CoroutineScope is cancelled; kotlinx.coroutines.CancellationException propagates unchanged.