WebSocketMessage class

Represents a WebSocket message with metadata and content.

Constructors

WebSocketMessage.new({required dynamic data, String type = 'text', DateTime? timestamp, String? id, bool requiresAck = false, int retryCount = 0, int maxRetries = 3})
Creates a new WebSocketMessage.
WebSocketMessage.binary(List<int> bytes, {DateTime? timestamp, String? id, bool requiresAck = false})
Creates a binary message.
WebSocketMessage.fromJson(Map<String, dynamic> json)
Creates a message from JSON representation.
factory
WebSocketMessage.json(Map<String, dynamic> json, {DateTime? timestamp, String? id, bool requiresAck = false})
Creates a JSON message.
WebSocketMessage.ping({DateTime? timestamp, String? id})
Creates a ping message.
WebSocketMessage.pong({DateTime? timestamp, String? id})
Creates a pong message.
WebSocketMessage.text(String text, {DateTime? timestamp, String? id, bool requiresAck = false})
Creates a text message.

Properties

canRetry bool
Returns true if this message can be retried.
no setter
data → dynamic
The message content/payload.
final
hashCode int
The hash code for this object.
no setteroverride
id String
Unique identifier for the message.
final
isBinary bool
Returns true if this message is a binary message.
no setter
isControl bool
Returns true if this message is a control message (ping/pong).
no setter
isJson bool
Returns true if this message is a JSON message.
no setter
isText bool
Returns true if this message is a text message.
no setter
maxRetries int
Maximum number of retry attempts.
final
requiresAck bool
Whether this message requires acknowledgment.
final
retryCount int
Retry count for failed message delivery.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timestamp DateTime
Timestamp when the message was created.
final
type String
The message type (text, binary, etc.).
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts the message to a JSON representation.
toString() String
A string representation of this object.
override
withRetry() WebSocketMessage
Creates a copy of this message with updated retry count.

Operators

operator ==(Object other) bool
The equality operator.
override