send method
Sends message to every other participant over the data channel.
Pass a String for a text frame or a List<int> for a binary one.
Frames larger than 15 KiB are rejected by the engine. reliable defaults
to retransmitted, ordered delivery; pass false for fire-and-forget with
lower latency.
A payload that never got onto the channel completes this future with a
VideoSDKError carrying the reason, on both platforms. Only a real
transport failure — ERROR_SEND_FAILED (3070) — also raises
Events.error; a channel that was not open (ERROR_MEDIA_NOT_READY,
3048) and an over-size payload (ERROR_PAYLOAD_TOO_LARGE, 3072) are the
caller's own state and stay quiet there, matching the JS SDK.
Implementation
Future<void> send(Object message, {bool reliable = true}) {
if (message is String) {
return _backend.sendData(text: message, reliable: reliable);
}
if (message is List<int>) {
return _backend.sendData(bytes: message, reliable: reliable);
}
throw ArgumentError.value(
message,
'message',
'send() takes a String or a List<int>',
);
}