DittoBus

class DittoBus

Send and receive messages with remote Ditto peers in the mesh.

Ditto Bus is separate from the replicated document database. It is used to send one-off messages or create continuous channels with other peers in the mesh, without any persistence. Messages are treated as opaque binary by Ditto and must be created and interpreted by your app.

Possible uses include:

  • Remote control systems

  • Tunnelling other protocols

  • Gaming

  • Voice and video

Ditto Bus communications are always between two distinct peers, 1-to-1, and are offered with various delivery guarantees.

For simple use cases there is a single-message API. These are received on the other peer via DittoBusCallback.

In advanced situations with requirements such as multiple overlapping streams, notification of stream start and end, and backpressure, individual streams can be opened using the openStream function. Once opened, these are symmetric/bidirectional message-oriented communication channels. The remote peer will receive their stream via DittoBusCallback.

Properties

Link copied to clipboard

Callbacks for global bus events

Functions

Link copied to clipboard
fun finishedSendingSingleMessage(sendCtx: BigInteger, reliability: ReliabilityMode_t, result: BusSingleSendResult_t)
Link copied to clipboard
fun newIncomingStream(siteId: BigInteger, peerKey: ByteArray, reliability: ReliabilityMode_t, streamID: BigInteger)
Link copied to clipboard

Open a dedicated stream handle to a remote peer at the nominated reliability level.

Link copied to clipboard

Send a single bus message to another peer, taking care that the message is delivered in full, if connectivity permits it.

Link copied to clipboard

Send a single bus message to another peer, with no guarantees on delivery.

Link copied to clipboard
fun singleMessageReceived(siteId: BigInteger, peerKey: ByteArray, data: ByteArray)
Link copied to clipboard
fun streamClosed(streamID: BigInteger, reason: BusCompletionReason_t)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun streamOpenSucceeded(openCtx: BigInteger, reliability: ReliabilityMode_t, streamID: BigInteger)
Link copied to clipboard
fun streamRemoteAck(streamID: BigInteger, messageSequence: BigInteger)
Link copied to clipboard
fun streamSendCompleted(streamID: BigInteger, result: Long, messageSequence: BigInteger)