Ditto

class Ditto @JvmOverloads constructor(dependencies: DittoDependencies, identity: DittoIdentity)

Ditto is the entry point for accessing Ditto-related functionality.

Parameters

dependencies

the dependencies required by the SDK to be initialised.

identity

the identity to be used to represent the connected client.

Constructors

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

Creates a Ditto instance.

Types

Companion
Link copied to clipboard
object Companion

Functions

getStore
Link copied to clipboard
fun getStore(): DittoStore

Provides access to the SDK's store functionality.

getTransportDiagnostics
Link copied to clipboard
fun getTransportDiagnostics(): DittoTransportDiagnostics

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

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

Request information about Ditto peers connected to this device.

observePeersV2
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.

refreshPermissions
Link copied to clipboard
fun refreshPermissions()

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

runGarbageCollection
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.

setAccessLicense
Link copied to clipboard
fun setAccessLicense(licenseToken: String)

Activate a Ditto instance by setting a license token. You cannot sync with Ditto before you have activated it.

setLicenseToken
Link copied to clipboard
fun setLicenseToken(licenseToken: String)

Activate a Ditto instance by setting a license token. You cannot sync with Ditto before you have activated it.

setTransportConfig
Link copied to clipboard
fun setTransportConfig(config: DittoTransportConfig)

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

startSync
Link copied to clipboard
fun startSync()

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

stopSync
Link copied to clipboard
fun stopSync()

Stops all network transports.

tryStartSync
Link copied to clipboard
fun tryStartSync()

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

Properties

activated
Link copied to clipboard
var activated: Boolean = false

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

auth
Link copied to clipboard
var auth: DittoAuthenticator? = null

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

callback
Link copied to clipboard
var callback: DittoCallback? = null

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

isSyncActive
Link copied to clipboard
var isSyncActive: Boolean = false

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

sdkVersion
Link copied to clipboard
val sdkVersion: String

Returns a string identifying the version of the Ditto SDK.

siteID
Link copied to clipboard
val siteID: BigInteger

The site ID component of the identity in use.

store
Link copied to clipboard
val store: DittoStore

Provides access to the SDK's store functionality.