net.kano.joscar.snac
Class ImmediateSnacQueueManager

java.lang.Object
  extended byImmediateSnacQueueManager
All Implemented Interfaces:
SnacQueueManager

public class ImmediateSnacQueueManager
extends java.lang.Object
implements SnacQueueManager

A SNAC queue manager that sends all SNACs immediately, only queueing SNACs during a pause.


Constructor Summary
ImmediateSnacQueueManager()
           
 
Method Summary
 void attached(ClientSnacProcessor processor)
          Called when this SNAC queue manager has been set as the SNAC queue manager for the given processor.
 void clearQueue(ClientSnacProcessor processor)
          Clears all pending (queued) SNAC commands in this SNAC manager for the given SNAC processor.
 void detached(ClientSnacProcessor processor)
          Called when this SNAC queue manager has been removed from being the SNAC queue manager for the given processor.
 void pause(ClientSnacProcessor processor)
          A method called to indicate that the queue should be paused until a call to unpause(net.kano.joscar.snac.ClientSnacProcessor).
 void queueSnac(ClientSnacProcessor processor, SnacRequest request)
          Enqueues the given SNAC request for the given SNAC processor.
protected static void sendSnac(ClientSnacProcessor processor, SnacRequest req)
          Sends the given SNAC request over the given processor, bypassing the queue.
 void unpause(ClientSnacProcessor processor)
          A method called to indicate that the queue for the given SNAC processor can once again send SNACs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImmediateSnacQueueManager

public ImmediateSnacQueueManager()
Method Detail

attached

public void attached(ClientSnacProcessor processor)
Description copied from interface: SnacQueueManager
Called when this SNAC queue manager has been set as the SNAC queue manager for the given processor. This will always be the first method called in this queue manager for the given SNAC processor.

Specified by:
attached in interface SnacQueueManager
Parameters:
processor - the SNAC processor for which this manager has been set

detached

public void detached(ClientSnacProcessor processor)
Description copied from interface: SnacQueueManager
Called when this SNAC queue manager has been removed from being the SNAC queue manager for the given processor. This method will always be the last method called in this queue manager for the given SNAC processor unless this manager is re-set as the given processor's queue manager, in which case the next method to be called for the given processor will always be attached.

Specified by:
detached in interface SnacQueueManager
Parameters:
processor - the SNAC processor for which this manager has been set

pause

public void pause(ClientSnacProcessor processor)
Description copied from interface: SnacQueueManager
A method called to indicate that the queue should be paused until a call to SnacQueueManager.unpause(net.kano.joscar.snac.ClientSnacProcessor). This method will never be called for a given ClientSnacProcessor twice without a call to unpause in between; that is, it will never be called twice in a row. Note that calls to SnacQueueManager.queueSnac(net.kano.joscar.snac.ClientSnacProcessor, net.kano.joscar.snac.SnacRequest) can and probably will be made before a call to SnacQueueManager.unpause(net.kano.joscar.snac.ClientSnacProcessor); that is, the queue must still accept the queueing of SNAC commands while it is paused.

Note that this will be the first method called for a given SNAC processor if this queue manager is added to the processor while the processor is paused.

Specified by:
pause in interface SnacQueueManager
Parameters:
processor - the SNAC processor on which to pause

unpause

public void unpause(ClientSnacProcessor processor)
Description copied from interface: SnacQueueManager
A method called to indicate that the queue for the given SNAC processor can once again send SNACs. This method will only be called after a call to SnacQueueManager.pause(net.kano.joscar.snac.ClientSnacProcessor), and will never be called twice for a SNAC processor without a call to SnacQueueManager.pause(net.kano.joscar.snac.ClientSnacProcessor) in between; that is, essentially, it will never be called twice in a row for a given SNAC processor.

Specified by:
unpause in interface SnacQueueManager
Parameters:
processor - the SNAC processor on which to pause

sendSnac

protected static final void sendSnac(ClientSnacProcessor processor,
                                     SnacRequest req)
Sends the given SNAC request over the given processor, bypassing the queue.

Parameters:
processor - the SNAC processor on which to send
req - the request to send

queueSnac

public void queueSnac(ClientSnacProcessor processor,
                      SnacRequest request)
Description copied from interface: SnacQueueManager
Enqueues the given SNAC request for the given SNAC processor. This method can just as easily send the given request immediately (via sendSnac) as it can enqueue it to be sent later. Note that the given request will not be sent at all until it is sent from this SNAC queue manager using sendSnac. It is not recommended that a request be modified before it is sent.

Specified by:
queueSnac in interface SnacQueueManager
Parameters:
processor - the SNAC processor on which the given request was created and on which it is to be sent
request - the request being enqueued

clearQueue

public void clearQueue(ClientSnacProcessor processor)
Description copied from interface: SnacQueueManager
Clears all pending (queued) SNAC commands in this SNAC manager for the given SNAC processor. This is normally only called when the given SNAC processor has been disconnected. Note that a call to this method implies a call to SnacQueueManager.unpause(net.kano.joscar.snac.ClientSnacProcessor) for the given SNAC processor as well, although no queued SNACs should be sent (as they might be with an actual call to unpause}.

Specified by:
clearQueue in interface SnacQueueManager
Parameters:
processor - the SNAC processor for which pending SNACs should be erased