Package org.astrogrid.samp.client

# 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 Summary

Constructors
Constructor
Description
`TrackedClientSet()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`addClient(Client client)`
Adds a client to this model.
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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