send

fun send(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 to the server over the shared socket. Safe to call from any thread, including while receiveLoop is blocked in a receive on another.

Return

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

Parameters

message

the text to send


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 to the server as the payload of one 0x90 unreliable application datagram ([0x90][channel][bytes]) over the shared socket. Safe to call from any thread. send(String) is a UTF-8 wrapper over the same private sendUnreliable this delegates to.

Any payload bytes are carried intact - there is no reserved first byte. A framed datagram above the OS datagram limit fails the returned 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 application payload