observe

fun observe(handler: (DittoPresenceGraph) -> Unit): DittoPresenceObserver

Request information about Ditto peers in the local peer-to-peer network. The V3 observer differs from observePeersV2 by delivering strongly typed objects with documentation in addition to an easy way to get a JSON representation of the presence object graph.

This method returns an observer which will invoke the provided lambda expression for each update. A newly registered observer will have a peers update delivered to it immediately. Then it will be invoked repeatedly when new information is learned about Ditto peers or their connections in the local peer-to-peer network.

When the observer is no longer required the caller must call close() on the returned DittoPresenceObserver.

Parameters

handler

the lambda expression to be invoked when there is an update.


fun observe(callback: DittoPresenceObserverCallback): DittoPresenceObserver

Request information about Ditto peers in the local peer-to-peer network. The V3 observer differs from observePeersV2 by delivering strongly typed objects with documentation in addition to an easy way to get a JSON representation of the presence object graph.

This method returns an observer which will invoke the update method on the provided callback object for each update. A newly registered observer will have an update delivered to it immediately. Then it will be invoked repeatedly when new information is learned about Ditto peers or their connections in the local peer-to-peer network.

When the observer is no longer required the caller must call close() on the returned DittoPresenceObserver.

Parameters

callback

an object that implements the DittoPresenceObserverCallback interface, whose update function will be called when there is an update.