DefaultJoinerReconnectController

class DefaultJoinerReconnectController(roomId: RoomId, reconnectWindowMs: Long = DEFAULT_RECONNECT_WINDOW_MS, clock: () -> Long, scope: CoroutineScope) : JoinerReconnectController

Default implementation of JoinerReconnectController.

Each disconnected peer gets an independent coroutine timer. The timer uses delay so kotlinx.coroutines.test.runTest's virtual time governs expiry — no wall-clock dependency.

Per-peer windows are independent: one peer's window expiring does not affect another peer's window.

Parameters

roomId

The Room this controller guards. Tokens for a different Room are rejected as ResumeResult.TokenInvalid.

reconnectWindowMs

Duration of the reconnect window in millis. Defaults to DEFAULT_RECONNECT_WINDOW_MS (60 s).

clock

Injected clock returning epoch-millis. Must never be wired to System.currentTimeMillis() from commonMain production code; the JVM wiring layer (your dependency injection container) passes { System.currentTimeMillis() }. Tests pass a fixed or advancing value so no wall-clock coupling escapes.

scope

Coroutine scope that owns per-peer timer jobs. Must outlive this controller; typically the Room's scope.

Constructors

Link copied to clipboard
constructor(roomId: RoomId, reconnectWindowMs: Long = DEFAULT_RECONNECT_WINDOW_MS, clock: () -> Long, scope: CoroutineScope)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun expire(peerId: PeerId, at: Long)

Force-expires the reconnect window for peerId before the timer fires.

Link copied to clipboard
open override fun onPeerUnresponsive(peerId: PeerId, at: Long)

Opens (or refreshes) the reconnect window for peerId.

Link copied to clipboard
open suspend override fun tryResume(token: ResumeToken, at: Long): ResumeResult

Attempts to resume the peer identified by token.