observePeers

fun observePeers(handler: (List<DittoRemotePeer>) -> Unit): DittoPeersObserver

Request information about Ditto peers connected to this device.

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 Ditto devices come and go, or the active connections to them change.

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

V1

Parameters

handler

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


fun observePeers(callback: DittoPeersObserverV1Callback): DittoPeersObserver

Request information about Ditto peers connected to this device.

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 a peers update delivered to it immediately. Then it will be invoked repeatedly when Ditto devices come and go, or the active connections to them change.

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

V1

Parameters

callback

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