startBytes

fun startBytes(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)

Raw-bytes counterpart to start: dispatches an exact-length, undecoded, untrimmed copy of every non-keepalive datagram to onMessage. Mutually exclusive with start - last call wins - and idempotent in the same way: calling this (or start, or channel(UNRELIABLE).actuate*) again rebinds the unreliable handler rather than starting a second listener thread. Call after handshake.

Control datagrams (0x80 keepalive, 0x81/0x82 probe) are classified out by their DatagramType tag; every 0x90 frame's stripped payload is delivered verbatim, so any payload bytes ride intact - there is no reserved first byte. The delivered copy is at most 65507 bytes; a larger inbound datagram is delivered truncated to that length, not rejected.

Return

Result.success once the listener thread is running, or the failure that prevented starting it

Parameters

onMessage

invoked with the raw body of every non-keepalive datagram; runs on the dispatch executor, not the caller's thread. A thrown exception is caught, logged, and does not stop the listener.