ditto-lib / live.ditto / DittoKit

DittoKit

class DittoKit : Closeable

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

dbConfig - optional config that will be used to configure the internal database store.

Constructors

<init>

DittoKit(dependencies: DittoKitDependencies, identity: DittoIdentity = DittoIdentity.Development(), dbConfig: DittoDBConfig = DittoDBConfig())

Creates a DittoKit instance.

Properties

activated

var activated: Boolean

flag indicating whether or not the SDK has been activated with an access license.

callback

var callback: DittoKitCallback?

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

dependencies

val dependencies: DittoKitDependencies

the dependencies required by the SDK to be initialised.

sdkVersion

val sdkVersion: String

Returns a string identifying the version of the DittoKit SDK.

siteID

val siteID: Long

the site ID component of the identity in use.

store

val store: DittoStore

provides access to the SDK's store functionality.

Functions

clearSiteID

fun clearSiteID(): Unit

Clears the cached site ID, if one had been cached.

close

fun close(): Unit

Closes the DittoKit instance so that its underlying resources are cleaned up appropriately.

finalize

fun finalize(): Unit

getTransportDiagnostics

fun getTransportDiagnostics(): TransportDiagnostics

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

observePeers

fun observePeers(handler: (List<RemotePeer>) -> Unit): PeersObserver

Request information about Ditto peers in range of this device.

refreshPermissions

fun refreshPermissions(): Unit

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

setAccessLicense

fun setAccessLicense(license: String): Unit

Activate a DittoKit instance by setting an access license. You cannot interact with DittoKit before you have activated it.

start

fun start(transports: Set<DittoTransports> = mutableSetOf( DittoTransports.WiFi, DittoTransports.Bluetooth )): Unit

Start a set of transports being used by DittoKit to connect to other devices. This has no effect if a provided transport is already started.

stop

fun stop(): Unit

Stop all transports

fun stop(transports: Set<DittoTransports>): Unit

Stop a set of transports from being used by DittoKit to connect to other devices.

Companion Object Properties

deviceName

var deviceName: String

Configure a custom identifier for the current device.

logger

var logger: DittoLogger

The logger that will be used to log all Ditto-related logs. A default one is set that logs to logcat.

loggingEnabled

var loggingEnabled: Boolean

Represents whether logging is enabled.

minimumLogLevel

var minimumLogLevel: LogLevel

The minimum log level at which logs will be logged, provided loggingEnabled is true.