Ditto  1.0.1
Public Member Functions | Properties | List of all members
DittoSDK.Ditto Class Reference

The entrypoint to the Ditto SDK. More...

Public Member Functions

unsafe Ditto (DittoIdentity identity=default, string workingDir="ditto")
 Initializes a new instance of the Ditto class. More...
 
void StartSync ()
 Starts the network transports. Ditto will connect to other devices. More...
 
void StopSync ()
 Stops all network transports. More...
 
void SetTransportConfig (DittoTransportConfig config)
 Assign a new transports configuration. By default peer-to-peer transports are enabled. More...
 
unsafe void SetAccessLicense (string license)
 Activate a Ditto instance by setting an access license. You cannot interact with Ditto before you have activated it. More...
 
DittoTransportDiagnostics TransportDiagnostics ()
 Request bulk status information about the transports. This is mostly intended for statistical or debugging purposes. More...
 
DittoPeersObserver ObservePeers (Action< List< DittoRemotePeer >> callback)
 Request information about Ditto peers in range of this device. This method returns an observer which should be held as long as updates are required. A newly registered observer will have a peers update delivered to it immediately. From then on it will be invoked repeatedly when Ditto devices come and go, or the active connections to them change. More...
 

Properties

bool Activated [get]
 Gets a value indicating whether or not the SDK has been activated. More...
 
unsafe ulong SiteId [get]
 Gets the unique identifier of a peer in Ditto's distributed mesh network. More...
 
DittoStore Store [get]
 Gets a reference to the embedded data store. More...
 
unsafe string SDKVersion [get]
 Gets a string identifying the version of the Ditto SDK. More...
 

Detailed Description

The entrypoint to the Ditto SDK.

For a Ditto instance to continue to connect to other devices it must be kept in scope.

Constructor & Destructor Documentation

◆ Ditto()

unsafe DittoSDK.Ditto.Ditto ( DittoIdentity  identity = default,
string  workingDir = "ditto" 
)
inline

Initializes a new instance of the Ditto class.

Parameters
identityProvide the identity of the entity that is interacting with Ditto.
workingDirThe directory that will be used to persist Ditto data.

Member Function Documentation

◆ ObservePeers()

DittoPeersObserver DittoSDK.Ditto.ObservePeers ( Action< List< DittoRemotePeer >>  callback)
inline

Request information about Ditto peers in range of this device. This method returns an observer which should be held as long as updates are required. A newly registered observer will have a peers update delivered to it immediately. From then on it will be invoked repeatedly when Ditto devices come and go, or the active connections to them change.

Parameters
callbackThe Action that will be invoked when there is a presence update.
Returns
A DittoPeersObserver instance, which must be retained to continue receiving callback updates.

◆ SetAccessLicense()

unsafe void DittoSDK.Ditto.SetAccessLicense ( string  license)
inline

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

Parameters
licenseThe access license.

◆ SetTransportConfig()

void DittoSDK.Ditto.SetTransportConfig ( DittoTransportConfig  config)
inline

Assign a new transports configuration. By default peer-to-peer transports are enabled.

You may use this method to alter the configuration at any time, however sync will not begin until startSync() is called.

Parameters
configThe new configuration to apply.

◆ StartSync()

void DittoSDK.Ditto.StartSync ( )
inline

Starts the network transports. Ditto will connect to other devices.

By default Ditto will enable all peer-to-peer transport types. The network configuration can be customized using the setTransportConfig method.

◆ StopSync()

void DittoSDK.Ditto.StopSync ( )
inline

Stops all network transports.

You may continue to use the database locally but no data will sync to or from other devices.

◆ TransportDiagnostics()

DittoTransportDiagnostics DittoSDK.Ditto.TransportDiagnostics ( )
inline

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

Returns
An instance of DittoTransportDiagnostics that represents the current state of the network transports that the SDK is using.

Property Documentation

◆ Activated

bool DittoSDK.Ditto.Activated
get

Gets a value indicating whether or not the SDK has been activated.

If false then you need to call Ditto.SetAccessLicense(string) before interacting with the SDK.

◆ SDKVersion

unsafe string DittoSDK.Ditto.SDKVersion
get

Gets a string identifying the version of the Ditto SDK.

Returns
A string identifying the version of the Ditto SDK.

◆ SiteId

unsafe ulong DittoSDK.Ditto.SiteId
get

Gets the unique identifier of a peer in Ditto's distributed mesh network.

IMPORTANT: This must be unique or the merging and conflict resolution will have unexpected behavior.

◆ Store

DittoStore DittoSDK.Ditto.Store
get

Gets a reference to the embedded data store.