WebSocketTransport class
WebSocket transport adapter.
Protocol contract (JSON frames): Outbound: { "type": "message|edit|delete|typing|read|react", "payload": {...} } Inbound: { "type": "message|edited|deleted|status|typing|read|presence|reaction", "payload": {...} }
NOTE: The serialization of Message to/from JSON depends on the host app
providing the appropriate MessageTypeRegistry. For simplicity this adapter
uses a raw Map — integrate your own codec by overriding encodeMessage and
decodeEvent.
- Implemented types
Constructors
- WebSocketTransport({required WebSocketConfig config})
Properties
- config → WebSocketConfig
-
final
-
events
→ Stream<
TransportEvent> -
Real-time event stream from the backend.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Unique identifier for this adapter (e.g. 'websocket', 'firestore').
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
connect(
) → Future< void> -
Opens the connection and starts emitting TransportEvents.
override
-
decodeMessage(
Map< String, dynamic> json) → Message? - Override to deserialize incoming message frames.
-
deleteMessage(
String messageId) → Future< DeliveryStatus> -
Deletes
messageIdon the backend.override -
disconnect(
) → Future< void> -
Closes the connection cleanly.
override
-
editMessage(
String messageId, Message updated) → Future< DeliveryStatus> -
Updates
updatedon the backend.messageIdis the local/remote ID of the message to replace.override -
encodeMessage(
Message m) → Map< String, dynamic> - Override to use your own Message ↔ JSON codec.
-
fetchConversation(
String id) → Future< Conversation> -
Loads the full Conversation snapshot at startup.
override
-
fetchHistory(
{required String conversationId, DateTime? before, int limit = 50}) → Future< List< Message> > -
Loads a page of history before
before(cursor-based pagination).override -
markRead(
String conversationId, DateTime readAt) → Future< void> -
Marks the conversation as read for the current user at
readAt.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reactToMessage(
String messageId, String emoji) → Future< void> -
Toggles an emoji reaction on
messageId.override -
sendMessage(
Message m) → Future< DeliveryStatus> -
Sends
mto the backend and returns its DeliveryStatus.override -
sendTyping(
String conversationId, {bool isTyping = true}) → Future< void> -
Emits a "typing" indicator.
isTyping=false stops it.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited