Class DittoPresenceGraph

java.lang.Object
com.ditto.java.DittoPresenceGraph

public final class DittoPresenceGraph extends Object
Represents the Ditto mesh network of peers and their connections between each other. The localPeer is the entrypoint, all others are remote peers known by the local peer (either directly or via other remote peers).
  • Method Details

    • getLocalPeer

      public @NonNull DittoPeer getLocalPeer()

      Returns the local peer in this presence graph.

      The local peer is usually the peer represented by the currently running Ditto instance. It serves as the entrypoint to the presence graph. All other peers in the graph are remote peers known by the local peer, either through direct connections or via other remote peers.

      Returns:
      the local DittoPeer.
    • getRemotePeers

      public @NonNull List<? extends @NonNull DittoPeer> getRemotePeers()

      Returns all remote peers known by the local peer.

      This includes peers that are directly connected to the local peer as well as peers that are reachable through other remote peers in the mesh network.

      Returns:
      a list of remote DittoPeer instances.
    • serializeToJson

      public @NonNull String serializeToJson()

      Serializes the presence graph to a JSON string.

      The JSON representation includes the local peer, all remote peers, and their connections, providing a complete snapshot of the mesh network topology.

      Returns:
      a JSON string representation of the presence graph.
      Throws:
      DittoException - if serialization fails.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object