ConnectionStateHolder

class ConnectionStateHolder(initialState: ConnectionState = ConnectionState.Disconnected, initialEpochs: ConnectionEpochs = ConnectionEpochs()) : ConnectionStateProvider(source)

Owns canonical connection state, epochs, and compatibility projections under one publication lock.

Constructors

Link copied to clipboard
constructor(initialState: ConnectionState = ConnectionState.Disconnected, initialEpochs: ConnectionEpochs = ConnectionEpochs())

Properties

Link copied to clipboard
open override val connectionEpochs: StateFlow<ConnectionEpochs>

Convenience view of monotonic departures and completed handshakes. Use connectionLifecycle when the counters must be correlated with a specific state, because independent StateFlow collections can observe different versions.

Link copied to clipboard
open override val connectionLifecycle: StateFlow<ConnectionLifecycle>

Atomically correlated canonical state and lifecycle evidence.

Link copied to clipboard
open override val connectionState: StateFlow<ConnectionState>

Canonical app-level connection state.

Functions

Link copied to clipboard
fun reset(state: ConnectionState = ConnectionState.Disconnected, epochs: ConnectionEpochs? = null)

Restores a known state, primarily for reusable test fakes. Epoch counters remain monotonic: omitting epochs applies the canonical transition into state, while an explicit value may only advance the counters. The publication version always advances so readers can distinguish the reset from the preceding snapshot.

Link copied to clipboard

Applies newState and advances epochs exactly once when the state changes.