Package org.astrogrid.samp.client
Class TrackedClientSet
java.lang.Object
org.astrogrid.samp.client.TrackedClientSet
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a client to this model.Returns an unmodifiable Map representing the client list.void
removeClient
(Client client) Removes a client from this model.void
setClients
(Client[] clients) Sets the contents of this model to a given list.void
updateClient
(Client client, boolean metaChanged, boolean subsChanged) Notifies listeners that a given client's attributes (may) have changed.
-
Constructor Details
-
TrackedClientSet
public TrackedClientSet()Constructor.
-
-
Method Details
-
addClient
Adds a client to this model. Listeners are informed. May be called from any thread.- Parameters:
client
- client to add
-
removeClient
Removes a client from this model. Listeners are informed. May be called from any thread.- Parameters:
client
- client to remove
-
setClients
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
Notifies listeners that a given client's attributes (may) have changed. May be called from any thread.- Parameters:
client
- modified clientmetaChanged
- true if metadata may have changed (false if known unchanged)subsChanged
- true if subscriptions may have changed (false if known unchanged)
-
getClientMap
Returns an unmodifiable Map representing the client list. Keys are client IDs and values areClient
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 aObject.notifyAll()
.- Returns:
- id -> Client map
-