ReconnectionStrategy class abstract
Abstract class for implementing reconnection strategies.
Reconnection strategies determine how and when to attempt reconnection after a WebSocket connection is lost. Implementations can use different algorithms such as exponential backoff, linear backoff, or fixed delays.
Example:
class CustomStrategy implements ReconnectionStrategy {
@override
Duration calculateDelay(int attemptNumber) {
return Duration(seconds: attemptNumber * 2);
}
@override
bool shouldReconnect(int attemptNumber, int maxAttempts) {
return attemptNumber <= maxAttempts;
}
@override
void reset() {
// Reset strategy state
}
}
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
calculateDelay(
int attemptNumber) → Duration - Calculates the delay before the next reconnection attempt.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Resets the strategy state.
-
shouldReconnect(
int attemptNumber, int maxAttempts) → bool - Determines if reconnection should be attempted.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited