Package org.astrogrid.samp.client
Class TrackedClientSet
- java.lang.Object
-
- org.astrogrid.samp.client.TrackedClientSet
-
- Direct Known Subclasses:
GuiHubConnector.ListModelTrackedClientSet
,ProxyManager.ProxyManagerClientSet
public class TrackedClientSet extends java.lang.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
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map
clientMap_
private java.util.Map
clientMapView_
-
Constructor Summary
Constructors Constructor Description TrackedClientSet()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClient(Client client)
Adds a client to this model.java.util.Map
getClientMap()
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.
-
-
-
Method Detail
-
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 clientmetaChanged
- true if metadata may have changed (false if known unchanged)subsChanged
- true if subscriptions may have changed (false if known unchanged)
-
getClientMap
public java.util.Map 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
-
-