Loom

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

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

Link copied to clipboard

Whether this fabric can be attempted now. Default FabricAvailability.Available; fabrics gated on a runtime capability override.

Link copied to clipboard
open suspend fun host(pattern: Pattern): Seam

Host / start a new session.

Link copied to clipboard
open suspend fun join(tag: Tag): Seam

Join an existing session. The advertisement carries enough info to reach the existing peer set.

Link copied to clipboard
abstract suspend fun weave(rendezvous: Rendezvous): Seam

Establish a Seam according to rendezvous — either host a new session or join an existing one.