VoxeraRoomMessageChannel class

The kit's room messaging socket: chat, app messages and likes for the room go through the engine, which caps and batches them for everyone.

The channel connects with the room's user token, reconnects on its own with a growing delay, and gives up for the session when the engine says the session may not use it (4003) or the project turned it off (4010). While it is not connected every send reports VoxeraRoomSendResult.unavailable, so the caller uses the data channel.

Constructors

VoxeraRoomMessageChannel({required VoxeraRoomMessagingInfo info, required String room, required String userToken(), required void onMessage(VoxeraRoomBatchMessage message), void onLikes(int delta, int total)?, bool isStillInRoom()?, Duration backoff(int attempt)?, Duration ackTimeout = const Duration(seconds: 5), Duration authTimeout = const Duration(seconds: 10), Duration likeFlushInterval = const Duration(milliseconds: 250)})

Properties

ackTimeout → Duration
final
authTimeout → Duration
final
connected → ValueNotifier<bool>
True while the socket is authenticated.
final
hashCode → int
The hash code for this object.
no setterinherited
info → VoxeraRoomMessagingInfo
final
isConnected → bool
no setter
isStillInRoom → bool Function()?
Whether the local user is still in the room. A 4011 close (this identity left, or the room ended) reconnects only while this is true.
final
isStopped → bool
True once the channel stopped for good (stop(), or the engine refused the session). The data channel carries everything from then on.
no setter
lastCloseCode → int?
The close code of the last socket, for logs and tests.
no setter
lastCloseReason → String?
The last reason the engine gave in room.closed, for logs and tests.
no setter
likeFlushInterval → Duration
final
onLikes → void Function(int delta, int total)?
Likes: the delta in this frame and the room total. A connect reports the total with a delta of 0.
final
onMessage → void Function(VoxeraRoomBatchMessage message)
final
room → String
The room name the app joined (not the media server's prefixed name).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
userToken → String Function()
The latest user token. Read on every (re)connect.
final

Methods

dispose() → void
like([int count = 1]) → bool
Adds count likes. Taps are summed and sent every likeFlushInterval. False while the socket is not connected (likes need the engine).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendChat({required String cid, required String text, String? senderName, Map<String, dynamic>? userData, String? chatMessageId}) → Future<VoxeraRoomSendResult>
Sends one chat line. cid is the id from newCid; the message id is messageId of the local identity and cid.
sendCustom({required String cid, required Map<String, dynamic> payload}) → Future<VoxeraRoomSendResult>
Sends one app message (a gift, a reaction …) as the app built it.
start() → void
stop() → Future<void>
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

canCarry(Map<String, dynamic> payload) → bool
Whether an app message may go on the room socket. Chat has its own send, and a type starting with _ is a kit or engine control message, which stays on the data channel.
defaultBackoff(int attempt) → Duration
1 s, 2 s, 4 s … up to 30 s, each ±20%.
identityFromMessageId(String? id) → String?
The sender named inside a message id, or null.
messageId(String identity, String cid) → String
The id the engine gives a message: rm:<base64url identity>:<cid>, or rm:~:<cid> for a very long identity. The kit builds it before sending so it can drop its own echo on the socket and on the data channel.
newCid() → String
A fresh id for one send.
sendOrFallback({required VoxeraRoomMessageChannel? channel, required String? identity, required void remember(String messageId), required Future<VoxeraRoomSendResult> send(VoxeraRoomMessageChannel channel, String cid), required Future<bool> viaDataChannel()}) → Future<bool>
Sends on the room socket when channel is connected and identity is known, otherwise through viaDataChannel (whose result is returned). remember gets the message id before the send, so the sender drops its own echo.

Constants

closeDisabled → const int
closeLeftRoom → const int
closeNotAllowed → const int