net.kano.joscar.ratelim
Class ConnectionQueueMgr

java.lang.Object
  extended byConnectionQueueMgr

public final class ConnectionQueueMgr
extends java.lang.Object

Manages the SNAC queue for a single SNAC processor (or "connection"). Instances of this class must be obtained from a RateLimitingQueueMgr's getQueueMgr or getQueueMgrs methods; an instance is created automatically upon assigning a RateLimitingQueueMgr as the SNAC queue manager for a given SNAC processor.


Method Summary
 RateLimitingQueueMgr getParentQueueMgr()
          Returns this SNAC connection queue manager's "parent" RateLimitingQueueMgr.
 RateMonitor getRateMonitor()
          Returns the rate monitor being used to determine when to send SNAC commands on the associated SNAC connection.
 RateQueue getRateQueue(CmdType type)
          Returns the rate queue in which a command of the given type would be placed.
 ClientSnacProcessor getSnacProcessor()
          Returns the SNAC processor whose rate queues are being managed by this queue manager.
 boolean isPaused()
          Returns whether the SNAC queue for the associated connection is currently paused.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getParentQueueMgr

public RateLimitingQueueMgr getParentQueueMgr()
Returns this SNAC connection queue manager's "parent" RateLimitingQueueMgr.

Returns:
the parent rate manager of this connection queue manager

getRateMonitor

public RateMonitor getRateMonitor()
Returns the rate monitor being used to determine when to send SNAC commands on the associated SNAC connection.

Returns:
the rate monitor being used

getSnacProcessor

public ClientSnacProcessor getSnacProcessor()
Returns the SNAC processor whose rate queues are being managed by this queue manager.

Returns:
the SNAC processor whose rate queues are being managed by this queue manager

getRateQueue

public RateQueue getRateQueue(CmdType type)
Returns the rate queue in which a command of the given type would be placed. Note that, normally, any number of calls to this method with the same command type will return a reference to the same RateQueue for the duration of the underlying SNAC connection. That is, RateQueue references can safely be kept for the duration of a SNAC connection. To be notified of when rate information changes, one could use code such as the following:
connQueueMgr.getRateMonitor().addListener(myRateListener);
 
When new rate information is received (that is, when RateListener.gotRateClasses(net.kano.joscar.ratelim.RateMonitor) is called), old rate queues are discarded and new ones are created as per the new rate information.

This method should only return null in the case that no rate information has yet been received or the server did not specify a default rate class (this is very abnormal behavior and will most likely never happen when using AOL's servers).

Parameters:
type - the command type whose rate queue is to be returned
Returns:
the rate queue used for the given command type

isPaused

public boolean isPaused()
Returns whether the SNAC queue for the associated connection is currently paused.

Returns:
whether the SNAC queue for the associated connection is currently paused
See Also:
ClientSnacProcessor.pause(), ClientSnacProcessor.unpause()