Class JsonMessageClientManager

java.lang.Object
jmri.server.json.message.JsonMessageClientManager
All Implemented Interfaces:
InstanceManagerAutoDefault

Manager for JSON streaming clients that are subscribing to messages triggered by out-of-channel events.
  • Field Details

  • Constructor Details

  • Method Details

    • subscribe

      public void subscribe(@Nonnull 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:
      IllegalArgumentException - if client is already in use for a different connection
    • unsubscribe

      public void unsubscribe(@CheckForNull 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

      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

      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