Class MessageSource

java.lang.Object
dev.ua.theroer.magicutils.messaging.MessageSource

public final class MessageSource extends Object
Identifies a member of the network for message origin and routing.

A source has a stable id (unique per running process) and a type distinguishing the proxy from backend servers. Backends additionally carry a server name as registered with the proxy, which the proxy uses to route Target.server(String) messages.

  • Method Details

    • proxy

      public static MessageSource proxy(String id)
      Creates a proxy source.
      Parameters:
      id - unique process id
      Returns:
      proxy source
    • backend

      public static MessageSource backend(String id, @Nullable @Nullable String serverName)
      Creates a backend source.
      Parameters:
      id - unique process id
      serverName - server name registered with the proxy (may be null when unknown)
      Returns:
      backend source
    • id

      public String id()
      Returns the unique process id of this member.
      Returns:
      member id
    • type

      public MessageSource.Type type()
      Returns the member type.
      Returns:
      member type
    • serverName

      @Nullable public @Nullable String serverName()
      Returns the backend server name, when known.
      Returns:
      server name, or null for proxies / unknown backends
    • isProxy

      public boolean isProxy()
      Returns whether this source is a proxy.
      Returns:
      true when a proxy
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object