Class TrackedClientSet

java.lang.Object
org.astrogrid.samp.client.TrackedClientSet

public class TrackedClientSet extends Object
Collection of Client objects which can be notified and interrogated about the clients which are currently registered. Instances of this class are thread-safe.
Since:
25 Nov 2008
Author:
Mark Taylor
  • Constructor Details

    • TrackedClientSet

      public TrackedClientSet()
      Constructor.
  • Method Details

    • addClient

      public void addClient(Client client)
      Adds a client to this model. Listeners are informed. May be called from any thread.
      Parameters:
      client - client to add
    • removeClient

      public void removeClient(Client client)
      Removes a client from this model. Listeners are informed. May be called from any thread.
      Parameters:
      client - client to remove
    • setClients

      public void setClients(Client[] clients)
      Sets the contents of this model to a given list. Listeners are informed. May be called from any thread.
      Parameters:
      clients - current client list
    • updateClient

      public void updateClient(Client client, boolean metaChanged, boolean subsChanged)
      Notifies listeners that a given client's attributes (may) have changed. May be called from any thread.
      Parameters:
      client - modified client
      metaChanged - true if metadata may have changed (false if known unchanged)
      subsChanged - true if subscriptions may have changed (false if known unchanged)
    • getClientMap

      public Map getClientMap()
      Returns an unmodifiable Map representing the client list. Keys are client IDs and values are Client objects.

      This map is synchronized which means that to iterate over any of its views you must synchronize on it. When the map or any of its contents changes, it will receive a Object.notifyAll().

      Returns:
      id -> Client map