actuateBytes

open fun actuateBytes(onMessage: (bytes: ByteArray) -> Unit): Result<Unit>(source)

Deprecated

Use channel(DeliveryMode.UNRELIABLE).actuateBytes(...) - see the 2.0 channel API

Replace with

import com.spartanlabs.webtools.udp.DeliveryMode
channel(DeliveryMode.UNRELIABLE).actuateBytes(onMessage)

Registers onMessage as the raw-bytes handler for datagrams from this client: it is handed an exact-length copy of each inbound datagram body - no UTF-8 decode, no .trim().

Mutually exclusive with actuate - the last call wins; binding a bytes handler clears any text handler and vice versa. A consumer that wants both views decodes inside the bytes handler.

Handshake and transport-control datagrams are filtered upstream on the DatagramType tag and never delivered here. The production transport frames this connection's data as an 0x90 unreliable datagram; any payload bytes are delivered intact - there is no reserved first byte.

The delivered copy is at most 65507 bytes (the maximum UDP payload over IPv4); an inbound datagram larger than that is delivered truncated to that length, not rejected.

The default implementation is a lossy UTF-8 round-trip over actuate; UDPConnection overrides it to deliver the datagram bytes verbatim.

Return

Result.success once the handler is registered, or the failure that prevented it

Parameters

onMessage

callback invoked with an exact-length copy of each datagram; it runs on the server's single-threaded dispatch executor, so it must return promptly