Ditto

class Ditto @JvmOverloads constructor(dependencies: DittoDependencies, identity: DittoIdentity = DittoIdentity.OfflinePlayground(dependencies)) : DittoBase

Ditto is the entry point for accessing Ditto-related functionality in the Android SDK.

Parameters

dependencies

the dependencies required by the SDK to be initialised.

identity

the identity to be used to represent the connected client.

Constructors

Link copied to clipboard
fun Ditto(dependencies: DittoDependencies, identity: DittoIdentity = DittoIdentity.OfflinePlayground(dependencies))

Creates a Ditto instance.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun allDisabledTransportsConfig(): DittoTransportConfig

Creates a default Android transport config which has all transports disabled.

Link copied to clipboard
open override fun close()

Shut down Ditto and release all resources. Must be called before recreating a Ditto instance that uses the same persistence directory.

Link copied to clipboard
fun disableSyncWithV3()

Explicitly opt-in to disabling the ability to sync with Ditto peers running any version of the SDK in the v3 (or lower) series of releases.

Link copied to clipboard
fun getTransportDiagnostics(): DittoTransportDiagnostics

Request bulk status information about the transports. This is mostly intended for statistical or debugging purposes.

Link copied to clipboard
fun observePeers(handler: (List<DittoRemotePeer>) -> Unit): DittoPeersObserver
fun observePeers(callback: DittoPeersObserverV1Callback): DittoPeersObserver

Request information about Ditto peers connected to this device.

Link copied to clipboard
fun observePeersV2(handler: (String) -> Unit): DittoPeersObserver
fun observePeersV2(callback: DittoPeersObserverV2Callback): DittoPeersObserver

Request information about Ditto peers in the local peer-to-peer network. The V2 observer differs from observePeers by providing not just information about the immediate peers, but also multihop information from other peers not immediately connected. V2 presence therefore offers a more complete view of the local peer-to-peer network.

Link copied to clipboard
fun refreshPermissions()

Provide a hint to Ditto that app permissions may have changed.

Link copied to clipboard
fun runGarbageCollection()

Removes all sync metadata for any remote peers which aren't currently connected. This method shouldn't usually be called. Manually running garbage collection often will result in slower sync times. Ditto automatically runs a garbage a collection process in the background at optimal times.

Link copied to clipboard
fun setOfflineOnlyLicenseToken(licenseToken: String)

Activate an offline Ditto instance by setting a license token. You cannot sync with Ditto before you have activated it. The offline license token is only valid for manual, offlinePlayground, and sharedKey identities.

Link copied to clipboard
open fun startSync()

Starts the network transports. Ditto will connect to other devices and sync with them where appropriate.

Link copied to clipboard
open fun stopSync()

Stops all network transports.

Properties

Link copied to clipboard
var activated: Boolean = false

A flag indicating whether or not the SDK has been activated with a valid license token.

Link copied to clipboard
var appId: String? = null

The App ID component of the identity in use.

Link copied to clipboard
var auth: DittoAuthenticator? = null

Provides access to authentication information and methods for logging on to Ditto Cloud.

Link copied to clipboard
var callback: DittoCallback? = null

An optional callback that will be called with lifecycle events relating to the SDK.

Link copied to clipboard
var deviceName: String

Configure a custom identifier for the current device.

Link copied to clipboard
val diskUsage: DiskUsage

Provides access to the SDK's store functionality.

Link copied to clipboard
var isSyncActive: Boolean = false

A flag indicating whether or not sync is active. Use startSync() to activate and stopSync() to deactivate sync.

Link copied to clipboard
val persistenceDirectory: String

Path to the persistence directory in use.

Link copied to clipboard
val presence: Presence

3rd version of presence. Use getPresence() to call from Java.

Link copied to clipboard
val sdkVersion: String

Returns a string identifying the version of the Ditto SDK.

Link copied to clipboard
val siteId: BigInteger

The site identifier component of the identity in use.

Link copied to clipboard
val store: DittoStore

Provides access to the SDK's store functionality.

Link copied to clipboard
var transportConfig: DittoTransportConfig

Assign a new transports configuration. By default peer-to-peer transports (Bluetooth and WiFi) are enabled.