ch.epfl.lpd.ids.client
Class ClientListFetcher

java.lang.Object
  extended by java.util.Observable
      extended by ch.epfl.lpd.ids.client.ClientListFetcher
All Implemented Interfaces:
Runnable

public class ClientListFetcher
extends Observable
implements Runnable

Thread used to retrieve the list of the connected clients. This thread is started/stopped whenever the user clicks on the connect/disconnect button of the ClientGUI.

Author:
Sebastien Baehni

Field Summary
protected  IServer server
          The reference to the IServer.
protected  boolean started
          Boolean to know if the thread has been started or not.
 
Constructor Summary
ClientListFetcher(IServer server, Observer observer)
          Creates a new instance of ClientListFetcher.
 
Method Summary
 void run()
          Main run method that fetch the list of connected chat clients on the server.
 void setStarted(boolean bool)
          Setter for the started boolean
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

started

protected boolean started
Boolean to know if the thread has been started or not.


server

protected IServer server
The reference to the IServer. This reference is used to retrieve the list of connected clients.

Constructor Detail

ClientListFetcher

public ClientListFetcher(IServer server,
                         Observer observer)
Creates a new instance of ClientListFetcher.

Parameters:
server - The reference to the IServer.
observer - The ClientGUI that is update evertime a list of clients is retrieved.
Method Detail

setStarted

public void setStarted(boolean bool)
Setter for the started boolean

Parameters:
bool - The boolean used to set the thread to be started or not.

run

public void run()
Main run method that fetch the list of connected chat clients on the server. This method does not block and polls the server every three seconds. Usually it is better to do passive waiting, but for this special case, we can use active waiting.

Specified by:
run in interface Runnable