This content is for SDK V4. For the latest version, see the V5 documentation.
- Setting and updating peer-specific information, such as name, role, and location.
- Viewing information about other peers currently connected in the mesh.
Accessing Presence APIs
To access API methods for mesh presence functionality, call thepresence namespace on the root Ditto object:
Presence Graph
Once discovered in the mesh, peers automatically establish a presence graph by advertising their device presence within the mesh and forming network connections with other connected peers. The presence graph is a data structure representing the current state of the mesh from a specific peer’s point of view. You can integrate the presence graph into your app to enable end-user functionality like network monitoring, management, and transport optimization. For example, once implemented, end users can input personal information, such as their name, and inspect remote peers connected within the mesh. For more information, see DittoSwiftTools on GitHub.Accessing Presence Graphs
To view your current presence graph:localPeer is the metadata set by the end user within your app. The remotePeers property provides an array of the other client devices connected to the mesh. (See End-User Defined Metadata for more information.)
Observing Presence Graph Modifications
To monitor and handle changes observed to the presence graph, call the change handler with the updated graph object as follows:Peer Key Identifier
Once discovered in the mesh, each peer device running Ditto is automatically assigned a peer key.Reading Peer Keys
View your local device’s peer key or the peer key identifying a specific remote device:- To retrieve the peer key for the current peer:
- To retrieve the peer key for a remote peer:
End-User Defined Peer Metadata
Using the peer-metadata property, you can provide each peer connected within the mesh the ability to set and view information about themselves or read information defined by other peers within the mesh. The following table provides an overview of key considerations to know before setting peer metadata, as well as Ditto’s recommended best practices to ensure optimal mesh performance and avoid potential issues:Setting Local Peer Metadata
To implement functionality providing end users the ability to define metadata, call thesetPeerMetadata API method as follows: