ResilientWebSocketOptions class
Tuning knobs for a ResilientWebSocket.
Constructors
- ResilientWebSocketOptions({bool autoReconnect = true, int maxReconnectAttempts = 0, Duration keepAliveInterval = const Duration(seconds: 5), String keepAliveMessage = '{"type":"KeepAlive"}', bool sendKeepAliveOnlyWhenIdle = false, Duration minReconnectDelay = const Duration(seconds: 1), Duration maxReconnectDelay = const Duration(seconds: 30), Duration connectTimeout = const Duration(seconds: 15), int corroboratedFailureThreshold = 2, bool shouldReconnect(WsCloseContext context)?, void onReconnecting(WsReconnectContext context)?, void onReconnected()?})
-
Creates an options bundle.
const
Properties
- autoReconnect → bool
-
Whether the socket reconnects automatically after unexpected
disconnects.
final
- connectTimeout → Duration
-
Timeout for establishing each connection.
final
- corroboratedFailureThreshold → int
-
Consecutive corroborated failures (definitive failure + healthy
internet) required before the SDK gives up and reports
WsConnectionState.failed.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- keepAliveInterval → Duration
-
Interval between application-level KeepAlive messages.
final
- keepAliveMessage → String
-
The KeepAlive control message sent on the interval.
final
- maxReconnectAttempts → int
-
Hard cap on reconnection attempts;
0means unlimited.final - maxReconnectDelay → Duration
-
Upper bound for reconnect backoff.
final
- minReconnectDelay → Duration
-
Lower bound for reconnect backoff.
final
- onReconnected → void Function()?
-
Callback invoked when a connection is (re)established after at least
one failure. Use this to re-send protocol setup (e.g. agent Settings).
final
- onReconnecting → void Function(WsReconnectContext context)?
-
Callback invoked before waiting out a backoff delay.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sendKeepAliveOnlyWhenIdle → bool
-
When
true, KeepAlive is only sent if no outbound traffic occurred recently (recommended for the Voice Agent API; the media streaming APIs accept unconditional keepalives).final - shouldReconnect → bool Function(WsCloseContext context)?
-
Callback deciding whether to schedule another reconnect. Return
falseto give up. Whennull, the default policy applies: stop after corroboratedFailureThreshold consecutive definitive failures with a healthy internet probe (e.g. bad credentials); retry everything else indefinitely.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited