Class DittoPeer

java.lang.Object
com.ditto.java.DittoPeer

public final class DittoPeer extends Object
An instance of Ditto taking part in the mesh network.
  • Method Details

    • getAddress

      public @NonNull DittoAddress getAddress()
      Returns the unique network identifier of the peer.
      Returns:
      the DittoAddress of this peer.
    • getConnections

      public @NonNull List<? extends @NonNull DittoConnection> getConnections()
      Returns the connections that are currently active with the current peer.
      Returns:
      a list of DittoConnection instances representing active connections.
    • getDeviceName

      public @NonNull String getDeviceName()
      Returns the human-readable device name of the peer. This defaults to the hostname but can be manually set by the application developer of the other peer. It is not necessarily unique.
      Returns:
      the device name string.
    • getDittoSdkVersion

      public @Nullable String getDittoSdkVersion()
      Returns the Ditto SDK version the peer is running with.
      Returns:
      the SDK version string, or null if unknown.
    • getIdentityServiceMetadata

      public @NonNull Map<@NonNull String,@Nullable ?> getIdentityServiceMetadata()
      Returns metadata associated with the peer by the identity service. Use an authentication webhook to set this value. See Ditto's online documentation for more information on how to configure an authentication webhook.
      Returns:
      a map of identity service metadata.
    • isCompatible

      public @Nullable Boolean isCompatible()
      Indicates whether the peer is compatible with the current peer.
      Returns:
      true if compatible, false if incompatible, or null if compatibility is unknown.
    • isConnectedToDittoCloud

      public boolean isConnectedToDittoCloud()
      Indicates whether the peer is connected to the Ditto Cloud (big peer).
      Returns:
      true if connected to Ditto Cloud, false otherwise.
    • getOs

      public @Nullable String getOs()
      Returns the operating system of the peer, if known. This detail is learned gradually and may not be known immediately.
      Returns:
      the OS string, or null if unknown.
    • getPeerKey

      public @NonNull String getPeerKey()
      Returns the peer key, a unique identifier for this peer. The peer key is equal to or derived from the cryptographic public key used to authenticate it.
      Returns:
      the peer key string.
      Implementation Note:
      This will be empty when a peer is not updated to the latest version of the SDK.
    • getPeerMetadata

      public @NonNull DittoJsonSerializable.ObjectValue getPeerMetadata()
      Returns metadata associated with the peer, empty dictionary by default. Use DittoPresence.setPeerMetadata(DittoJsonSerializable.ObjectValue) or DittoPresence.setPeerMetadataJsonString(String) to set this value. Peer metadata is dynamic and may change over the lifecycle of the DittoPresenceGraph. It may be empty when a remote peer initially appears in the presence graph and will be updated once the peer has synced its metadata with the local peer.
      Returns:
      a DittoJsonSerializable.ObjectValue containing the peer metadata.
      See Also:
    • 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