WebSocketConfig class

Configuration for WebSocket connections.

Constructors

WebSocketConfig.new({required String url, Duration connectionTimeout = const Duration(seconds: 30), bool enableReconnection = true, int maxReconnectionAttempts = 10, Duration initialReconnectionDelay = const Duration(seconds: 1), Duration maxReconnectionDelay = const Duration(minutes: 5), double backoffMultiplier = 2.0, bool enableMessageQueue = true, int maxQueueSize = 1000, Duration heartbeatInterval = const Duration(seconds: 30), bool enableHeartbeat = true, Map<String, String> headers = const {}, List<String> protocols = const [], bool enableCompression = false})
Creates a new WebSocketConfig.
const
WebSocketConfig.aggressive({required String url, Map<String, String> headers = const {}, List<String> protocols = const []})
Creates a WebSocketConfig with aggressive reconnection settings.
const
WebSocketConfig.fromJson(Map<String, dynamic> json)
Creates a config from JSON representation.
factory
WebSocketConfig.production({required String url, Map<String, String> headers = const {}, List<String> protocols = const []})
Creates a WebSocketConfig with default settings for production use.
const
WebSocketConfig.testing({required String url, Map<String, String> headers = const {}, List<String> protocols = const []})
Creates a WebSocketConfig with minimal settings for testing.
const

Properties

backoffMultiplier double
Multiplier for exponential backoff.
final
connectionTimeout Duration
Connection timeout in milliseconds.
final
enableCompression bool
Whether to enable compression.
final
enableHeartbeat bool
Whether to enable ping/pong heartbeat.
final
enableMessageQueue bool
Whether to enable message queuing.
final
enableReconnection bool
Whether to enable automatic reconnection.
final
hashCode int
The hash code for this object.
no setteroverride
headers Map<String, String>
Custom headers for the WebSocket connection.
final
heartbeatInterval Duration
Heartbeat interval in milliseconds.
final
initialReconnectionDelay Duration
Initial delay before first reconnection attempt.
final
maxQueueSize int
Maximum queue size for pending messages.
final
maxReconnectionAttempts int
Maximum number of reconnection attempts.
final
maxReconnectionDelay Duration
Maximum delay between reconnection attempts.
final
protocols List<String>
Protocols to use for the WebSocket connection.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url String
The WebSocket URL to connect to.
final

Methods

copyWith({String? url, Duration? connectionTimeout, bool? enableReconnection, int? maxReconnectionAttempts, Duration? initialReconnectionDelay, Duration? maxReconnectionDelay, double? backoffMultiplier, bool? enableMessageQueue, int? maxQueueSize, Duration? heartbeatInterval, bool? enableHeartbeat, Map<String, String>? headers, List<String>? protocols, bool? enableCompression}) WebSocketConfig
Returns a copy of this config with updated values.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts the config to a JSON representation.
toString() String
A string representation of this object.
override

Operators

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