ditto / live.ditto / Ditto / observePeers

observePeers

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

Request information about Ditto peers in range of this device.

This method returns an observer which will invoke the provided lambda 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 PeersObserver.

Parameters

handler - the lambda to be invoked when there is an update.

fun observePeers(callback: DittoPeersObserverCallback): DittoPeersObserver

Request information about Ditto peers in range of this device.

This method returns an observer which will invoke the provided lambda 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 PeersObserver.

Parameters

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