DittoBase

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

Base class for accessing Ditto-related functionality in the Android and Java SDKs. Use the Ditto class for your platform to create an instance.

Parameters

dependencies

the dependencies required by the SDK to be initialised.

identity

the identity to be used to represent the connected client.

Constructors

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

Creates a Ditto instance.

Types

Companion
Link copied to clipboard
object Companion

Functions

allDisabledTransportsConfig
Link copied to clipboard
abstract fun allDisabledTransportsConfig(): DittoTransportConfig

Since transports vary by platform, subclasses must implement this to return a config appropriate for the platform.

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.

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.

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

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
open fun stopSync()

Stops all network transports.

tryStartSync
Link copied to clipboard
open 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.

transportConfig
Link copied to clipboard
var transportConfig: DittoTransportConfig

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

Inheritors

Ditto
Link copied to clipboard