Connection

interface Connection

A point-to-point, message-oriented duplex link between exactly two peers.

The minimal SPI a message transport (WebSocket, gRPC bidi stream, Multipeer, Nearby) implements to become a kuilt fabric. Stream transports (TCP) do not implement this directly — they provide a kotlinx-io Source/Sink and use :kuilt-stream's framed() to obtain a Connection.

Each frame is a whole message; the link preserves frame boundaries and FIFO order.

Properties

Link copied to clipboard
abstract val incoming: Flow<ByteArray>

Whole messages received from the peer, in order. Single-collection.

Functions

Link copied to clipboard
abstract suspend fun close()

Close the link. Idempotent. Completes incoming.

Link copied to clipboard
abstract suspend fun send(frame: ByteArray)

Send one whole message. Suspends until the transport accepts it (backpressure).