i3mclient.polling
Class Polling

java.lang.Object
  |
  +--i3mclient.polling.Polling
All Implemented Interfaces:
Runnable

public class Polling
extends Object
implements Runnable

This class polls the I3M-server for new message. Polling is created as a Singleton Pattern

Author:
Gunther Wuerz

Field Summary
static int POLLING_DELAY
          Delay between pollings
 
Method Summary
 void addErrorListener(ErrorListener listener)
          Adds a new listener for any kind of errors into a internal list.
 void addMessageListener(MessageListener listener)
          Adds a new listener for all messages into a internal list.
 void addMessageListener(MessageListener listener, long discussionID)
          Adds a new listener for messages into a internal list.
static Polling getInstance()
          Returns an instance of this class (singleton construction)
 void init()
          Starts the polling thread.
 void removeErrorListener(ErrorListener listener)
          Remove a listener for any kind of errors from a internal list.
 void removeMessageListener(long discussionID, MessageListener listener)
          Removes a message listener out of the internal list.
 void removeMessageListener(MessageListener listener)
          Remove a listener for all messages from a internal list.
 void run()
           
 void stopPolling()
          Stops the polling thread.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLLING_DELAY

public static int POLLING_DELAY
Delay between pollings

Method Detail

getInstance

public static Polling getInstance()
Returns an instance of this class (singleton construction)

Returns:
The unique instance of this class

init

public void init()
Starts the polling thread.


stopPolling

public void stopPolling()
Stops the polling thread. Uses dirty flag "running" because thread.stop() is deprecated.


run

public void run()
Specified by:
run in interface Runnable

addMessageListener

public void addMessageListener(MessageListener listener,
                               long discussionID)
Adds a new listener for messages into a internal list. Listeners are identified by their discussionID.

Parameters:
listener - The listener which will be informed about new messages
discussionID - The listener will be only informed about messages with this discussionID

addMessageListener

public void addMessageListener(MessageListener listener)
Adds a new listener for all messages into a internal list.

Parameters:
listener - The listener which will be informed about all new messages

addErrorListener

public void addErrorListener(ErrorListener listener)
Adds a new listener for any kind of errors into a internal list.

Parameters:
listener - The listener which will be informed about errors

removeMessageListener

public void removeMessageListener(MessageListener listener)
Remove a listener for all messages from a internal list.

Parameters:
listener - The listener which will be no longer informed about all new messages

removeMessageListener

public void removeMessageListener(long discussionID,
                                  MessageListener listener)
Removes a message listener out of the internal list. The listener is indentified by its discussionID.

Parameters:
discussionID - Only listener with this discussionID will be removed
listener - The listener which will be removed

removeErrorListener

public void removeErrorListener(ErrorListener listener)
Remove a listener for any kind of errors from a internal list.

Parameters:
listener - The listener which will be no longer informed about errors