Loom
Establishes a Seam in the role of either an existing-session joiner or a new-session opener. The factory hides discovery (mDNS, MultipeerConnectivity advertising, WebSocket URL).
The single abstract method is weave; host and join are default wrappers. ADR-002.
Per-dial data
A fabric implementation that needs a value recomputed on every dial — most commonly a credential that must be refreshed on reconnect — accepts a Weft on its own constructor and invokes it inside weave. See Weft's KDoc for the full idiom; see KtorClientLoom/WebSocketSignalingChannel in :kuilt-websocket/:kuilt-webrtc for the first concrete uses.
Usage
Host a session, let a second peer join, and exchange a frame:
Samples
runTest {
val loom = InMemoryLoom()
val host = loom.host(Pattern("Alice"))
val joiner = loom.join(InMemoryTag("Bob"))
// collect one frame from the host's incoming flow
val receivedByHost = async {
host.incoming.first()
}
joiner.broadcast("hello".encodeToByteArray())
val frame = receivedByHost.await()
check(frame.decodeToString() == "hello")
check(frame.sender == joiner.selfId)
host.close()
joiner.close()
}Inheritors
Functions
Whether this fabric can be attempted now — the availability half of capability. Derived; do not override.
This fabric's role(s) and whether it can be attempted now. The single capability primitive — override this, not availability. Default: a roleless FabricAvailability.Available.
Establish a Seam according to rendezvous — either host a new session or join an existing one.