amip.api.highlevel
Class EventListenerManager

java.lang.Object
  extended by amip.api.highlevel.EventListenerManager

public class EventListenerManager
extends java.lang.Object

This class is used for operations with event listeners. You can easily configure listeners for the AMIP events you are interested in and be notified when they occur. For example, you can add ChangeEventListener to know when song changes in the player.

The instance of this class can be obtained from Server using Server.getEventListenersManager() method.


Method Summary
 void addEventListener(AEventListener l)
          Adds an event listener.
 void addMessageEventListener(MessageEventListener l)
          Adds listener for messages from AMIP.
 void fireEvent(java.lang.Class eventClass)
          Simulates event received from AMIP.
 void fireEvent(int code)
          Simulates event received from AMIP.
 void fireMessageEvent(java.lang.String msg)
          Simulates message event received from AMIP.
 int getListenerCount()
          May be useful to know if there are any listeners set.
 int getRetries()
           
 int getTimeout()
           
 void removeAllEventListeners()
          Removes all the event listeners.
 void removeEventListener(AEventListener l)
          Removes previously added event listener.
 void removeMessageEventListener(MessageEventListener l)
          Removes message listener.
 void setRetries(int retries)
          Sets number of retries before the listener is automatically removed from AMIP.
 void setTimeout(int timeout)
          Sets timeout for AMIP plugin while trying to connect to your Server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getListenerCount

public int getListenerCount()
May be useful to know if there are any listeners set.

Returns:
the number of listeners.

addEventListener

public void addEventListener(AEventListener l)
                      throws GeneralClientException
Adds an event listener.

Parameters:
l - the listener to add.
Throws:
GeneralClientException

removeEventListener

public void removeEventListener(AEventListener l)
                         throws GeneralClientException
Removes previously added event listener.

Parameters:
l - the listener to remove.
Throws:
GeneralClientException

addMessageEventListener

public void addMessageEventListener(MessageEventListener l)
                             throws GeneralClientException
Adds listener for messages from AMIP.

Parameters:
l - the listener to add.
Throws:
GeneralClientException

removeMessageEventListener

public void removeMessageEventListener(MessageEventListener l)
                                throws GeneralClientException
Removes message listener.

Parameters:
l - the listener to remove.
Throws:
GeneralClientException

removeAllEventListeners

public void removeAllEventListeners()
                             throws GeneralClientException
Removes all the event listeners. If you were listening for any events, either directly, or indirectly while working with the Playlist, before exiting your application you need to call this method. You have to call it before the uninit method of the Client.

Throws:
GeneralClientException

fireMessageEvent

public void fireMessageEvent(java.lang.String msg)
Simulates message event received from AMIP.

Parameters:
msg - a message string.

fireEvent

public void fireEvent(int code)
Simulates event received from AMIP.

Parameters:
code - event code.

fireEvent

public void fireEvent(java.lang.Class eventClass)
Simulates event received from AMIP.

Parameters:
eventClass - class of the event to fire.

getTimeout

public int getTimeout()

setTimeout

public void setTimeout(int timeout)
Sets timeout for AMIP plugin while trying to connect to your Server.

Parameters:
timeout - timeout in milliseconds.

getRetries

public int getRetries()

setRetries

public void setRetries(int retries)
Sets number of retries before the listener is automatically removed from AMIP.

Parameters:
retries - if AMIP can't notify you about the event this number of times, it will remove the listener and stop trying.