ReconnectConfig

data class ReconnectConfig(val maxAttempts: Int = DEFAULT_MAX_ATTEMPTS, val delayStrategy: RetryDelayStrategy = DEFAULT_DELAY_STRATEGY, val reconnectContext: CoroutineContext = EmptyCoroutineContext, val shouldReconnect: suspend (exception: Throwable, attempt: Int) -> Boolean = { _, _ -> true }, val afterReconnect: suspend (WebSocketConnection) -> Unit = {})(source)

Configuration for web socket reconnections.

Constructors

Link copied to clipboard
constructor(maxAttempts: Int = DEFAULT_MAX_ATTEMPTS, delayStrategy: RetryDelayStrategy = DEFAULT_DELAY_STRATEGY, reconnectContext: CoroutineContext = EmptyCoroutineContext, shouldReconnect: suspend (exception: Throwable, attempt: Int) -> Boolean = { _, _ -> true }, afterReconnect: suspend (WebSocketConnection) -> Unit = {})

Properties

Link copied to clipboard

A callback called each time the web socket is successfully reconnected.

Link copied to clipboard

Defines the time to wait before each reconnection attempt.

Link copied to clipboard

The maximum number of reconnection attempts before giving up.

Link copied to clipboard

An additional coroutine context for the coroutine that handles reconnections.

Link copied to clipboard
val shouldReconnect: suspend (exception: Throwable, attempt: Int) -> Boolean

A predicate to decide whether the web socket should be reconnected when the given exception occur. The attempt parameter is the index of the current reconnection attempt in a series of retries.