WebSocketMessage.fromJson constructor

WebSocketMessage.fromJson(
  1. Map<String, dynamic> json
)

Creates a message from JSON representation.

Implementation

factory WebSocketMessage.fromJson(Map<String, dynamic> json) {
  return WebSocketMessage(
    id: json['id'] as String,
    type: json['type'] as String,
    data: json['data'],
    timestamp: DateTime.parse(json['timestamp'] as String),
    requiresAck: json['requiresAck'] as bool? ?? false,
    retryCount: json['retryCount'] as int? ?? 0,
    maxRetries: json['maxRetries'] as int? ?? 3,
  );
}