Options

data class Options(val key: String = generateClientKey(), val apiKey: String? = null, val metadata: Map<String, String> = emptyMap(), val fetchAuthToken: suspend (shouldRefresh: Boolean) -> String? = null, val syncLoopDuration: Duration = 50.milliseconds, val reconnectStreamDelay: Duration = 1_000.milliseconds, val channelHeartbeatInterval: Duration = 5_000.milliseconds, val documentPollInterval: Duration = 3_000.milliseconds, val watchFallbackDelay: Duration = 10_000.milliseconds, val docStore: DocStore? = null, val sessionLock: SessionLock = NoopSessionLock, val watchHeartbeatInterval: Duration = 20_000.milliseconds)

User-settable options used when defining Client.

Constructors

Link copied to clipboard
constructor(key: String = generateClientKey(), apiKey: String? = null, metadata: Map<String, String> = emptyMap(), fetchAuthToken: suspend (shouldRefresh: Boolean) -> String? = null, syncLoopDuration: Duration = 50.milliseconds, reconnectStreamDelay: Duration = 1_000.milliseconds, channelHeartbeatInterval: Duration = 5_000.milliseconds, documentPollInterval: Duration = 3_000.milliseconds, watchFallbackDelay: Duration = 10_000.milliseconds, docStore: DocStore? = null, sessionLock: SessionLock = NoopSessionLock, watchHeartbeatInterval: Duration = 20_000.milliseconds)

Properties

Link copied to clipboard
val apiKey: String? = null

API key of the project used to identify the project.

Link copied to clipboard

channelHeartbeatInterval is the interval of the channel heartbeat. The client sends a heartbeat to the server to refresh the channel TTL. Applies to both Realtime and Manual/Polling channels. The default value is 5000(ms) — TTL/3 for the server's 15s ChannelSessionTTL. Mirrors JS SDK v0.7.10.

Link copied to clipboard
val docStore: DocStore? = null

Backing store for offline local persistence. When set, attachDocument resumes a previously Document.toBytes-persisted envelope before contacting the server, and the document is persisted again on every local change, local presence change, and successful sync. Unset (the default) disables persistence entirely — no load, no lease, no writes.

Link copied to clipboard

documentPollInterval is the push-pull interval for documents attached with SyncMode.Polling. Unused in other sync modes. The default value is 3000(ms). Mirrors JS SDK PR #1243.

Link copied to clipboard
val fetchAuthToken: suspend (shouldRefresh: Boolean) -> String? = null

fetchAuthToken provides a token for the auth webhook. When the webhook response status code is 401, this function is called to refresh the token. The reason parameter is the reason from the webhook response.

Link copied to clipboard
val key: String

Client key used to identify the client. If not set, a random key is generated — generateClientKey, freshly minted per Client instance, so it differs on every launch.

Link copied to clipboard

metadata is the metadata of the client. It is used to store additional information about the client.

Link copied to clipboard

Delay of the reconnect stream. If the stream is disconnected, the client waits for the delay to reconnect the stream. The default value is 1000(ms).

Link copied to clipboard

Single-active-session guard used when docStore is set, to prevent two sessions from concurrently resuming the same persisted document under the same stable actor (which would mint colliding clientSeq values and silently lose edits). Defaults to NoopSessionLock: unlike a browser with multiple tabs, an Android app is one process per store by default, so the hazard this guards against is reachable only when docStore is itself shared across processes. Ignored when docStore is unset. Ported from JS client.ts's sessionLock option; JS's browser-only deactivateOnUnload auto-default has no Android analog (no page-unload event) and is not ported.

Link copied to clipboard

Duration of the sync loop. After each sync loop, the client waits for the duration to next sync. The default value is 50(ms).

Link copied to clipboard

watchFallbackDelay is how long a realtime document's watch stream may stay silent (no frame of any kind received) before that attachment starts pulling on every sync-loop tick (throttled to documentPollInterval) as if it were Polling — i.e. degrades toward polling semantics per-attachment until a watch frame arrives again. This bounds staleness instead of the permanent pull starvation a silently-dead watch stream otherwise causes (a dead watch stream never flips changeEventReceived, so pull would never re-engage on its own — see #351).

Link copied to clipboard

watchHeartbeatInterval is the interval at which the client asks the server to send a heartbeat on an idle Watch stream, so that a half-open stream is noticed and reconnected (watchIdleTimeoutMs, c69e6bda/#1472). It is a request, not a setting: the server clamps it to its own bounds and the client times a silent stream out at three times the interval the server actually settles on and advertises back on the init frame. A non-positive value asks for no heartbeats, which also leaves the stream without an idle timeout. The default value is 20000(ms).