Class JsonMessageClientManager

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.HashMap<java.lang.String,​JsonConnection> clients  
      (package private) com.fasterxml.jackson.databind.ObjectMapper mapper  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getClient​(JsonConnection connection)
      Get the first client name associated with a connection.
      java.util.Set<java.lang.String> getClients​(JsonConnection connection)
      Get all client names associated with a connection.
      void send​(JsonMessage message)
      Send a message to a client or clients.
      void subscribe​(java.lang.String client, JsonConnection connection)
      Subscribe to the message service.
      void unsubscribe​(java.lang.String client)
      Cancel the subscription for a single client.
      void unsubscribe​(JsonConnection connection)
      Cancel the subscription for all clients on a given connection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • subscribe

        public void subscribe​(@Nonnull
                              java.lang.String client,
                              @Nonnull
                              JsonConnection connection)
        Subscribe to the message service.
        Parameters:
        client - the client identifier to use for the subscription
        connection - the connection associated with client
        Throws:
        java.lang.IllegalArgumentException - if client is already in use for a different connection
      • unsubscribe

        public void unsubscribe​(@CheckForNull
                                java.lang.String client)
        Cancel the subscription for a single client.
        Parameters:
        client - the client canceling the subscription
      • unsubscribe

        public void unsubscribe​(@CheckForNull
                                JsonConnection connection)
        Cancel the subscription for all clients on a given connection.
        Parameters:
        connection - the connection canceling the subscription
      • send

        public void send​(@Nonnull
                         JsonMessage message)
        Send a message to a client or clients. The determination of a single client or all clients is made using JsonMessage.getClient().
        Parameters:
        message - the message to send
      • getClient

        @CheckForNull
        public java.lang.String getClient​(@Nonnull
                                          JsonConnection connection)
        Get the first client name associated with a connection.
        Parameters:
        connection - the connection to get a client for
        Returns:
        the client or null if the connection is not subscribed
      • getClients

        public java.util.Set<java.lang.String> getClients​(@Nonnull
                                                          JsonConnection connection)
        Get all client names associated with a connection.
        Parameters:
        connection - the connection to get clients for
        Returns:
        a set of clients or an empty set if the connection is not subscribed