UdpChannel

interface UdpChannel(source)

A delivery-mode-scoped view of one connection: send under this mode's guarantees, and bind the handler for traffic that arrives under it. Stateless and cheap - hold it, or fetch it per call; either is correct.

Reachable as connection.channel(mode) on the server side and client.channel(mode) on the client side. channel(...) itself is an accessor, not a fallible operation - it always returns a handle; the Result lives on send / actuate / actuateBytes.

Stable Core. Full semver guarantee — breaking changes only in a major.

Types

Link copied to clipboard
object Companion

The reliable message-size constants: DEFAULT_MAX_RELIABLE_MESSAGE_BYTES and MAX_RELIABLE_MESSAGE_BYTES.

Properties

Link copied to clipboard
abstract val mode: DeliveryMode

The delivery guarantee this handle provides.

Functions

Link copied to clipboard
open fun actuate(onMessage: (message: String) -> Unit): Result<Unit>

Binds onMessage as the text handler for inbound traffic on this channel: each message decoded as UTF-8 and .trim()ed, matching Connection.actuate's long-standing semantics exactly. For a binary or whitespace-significant payload use actuateBytes.

Link copied to clipboard
abstract fun actuateBytes(onMessage: (bytes: ByteArray) -> Unit): Result<Unit>

Binds onMessage as the raw-bytes handler for inbound traffic on this channel: an exact-length, undecoded, untrimmed copy of each message. Per-mode: binding a reliable handler does not disturb the unreliable one, and vice versa.

Link copied to clipboard
abstract fun send(bytes: ByteArray): Result<Unit>

Sends bytes under mode's guarantees.

open fun send(message: String): Result<Unit>

UTF-8 convenience over send(ByteArray).