RoomHost

Accepts incoming connections and surfaces each as an admitted Room.

A host is the entry point a fabric adapter wraps so consumers can run a session without knowing the transport: a Ktor WebSocket host, an Apple-Multipeer host, or the transport-agnostic LoomRoomHost over any Loom.

Why this interface exists. It lets a consumer drive the full admit handshake (Hello → Welcome → onPeer) deterministically under runTest virtual time by substituting a LoomRoomHost backed by an us.tractat.kuilt.core.InMemoryLoom for the production host — exercising the real host code path without binding a socket or standing up a server engine.

Cardinality. start's onRoom is invoked once per admitted connection. A single-room host (LoomRoomHost, a Multipeer host) invokes it exactly once and then suspends; a multi-room accept-loop host (the Ktor WebSocket host) invokes it for every connection that arrives.

Inheritors

Functions

Link copied to clipboard
expect abstract fun close()
Link copied to clipboard
abstract suspend 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.