push

abstract fun push(message: String): Result<Unit>(source)

Deprecated

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

Replace with

import com.spartanlabs.webtools.udp.DeliveryMode
channel(DeliveryMode.UNRELIABLE).send(message)

Sends message as the body of one datagram to peer over the server's shared socket. This is the abstract send primitive; the default push(ByteArray) delegates to it via a UTF-8 decode unless an implementor overrides that overload to send raw bytes.

This is how a subclass sends to one specific client over the shared channel - key connections by name or peer and call push on the one you want; MultiConnectionUDPServer.pushToAll is the broadcast-to-everyone path, not the only per-client path.

Return

Result.success if the message was sent, or the failure that prevented it

Parameters

message

the text to send


open fun push(bytes: ByteArray): Result<Unit>(source)

Deprecated

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

Replace with

import com.spartanlabs.webtools.udp.DeliveryMode
channel(DeliveryMode.UNRELIABLE).send(bytes)

Sends bytes as one raw datagram to peer over the server's shared socket: the payload is placed on the wire verbatim - no encoding, no trim.

The default implementation round-trips through push(String) and is therefore lossy for non-UTF-8 payloads; UDPConnection overrides it to frame the bytes as an 0x90 unreliable datagram and send them unchanged. Any payload bytes are delivered to the peer intact.

A payload larger than the OS datagram limit fails the Result (the cause is logged) rather than being sent; for real-network use keep frames under the path MTU (~1200 bytes) to avoid IP fragmentation.

Return

Result.success if the datagram was sent, or the failure that prevented it

Parameters

bytes

the raw datagram payload