com.bolinfest.prisonerbot
Class AbstractMessageProxy

java.lang.Object
  extended by com.bolinfest.prisonerbot.AbstractMessageProxy
All Implemented Interfaces:
MessageProxy
Direct Known Subclasses:
DaimProxy, JabberProxy

public abstract class AbstractMessageProxy
extends Object
implements MessageProxy

AbstractMessageProxy is an Abstract implementation of MessageProxy where sendMessage() does not send the message -- it puts the message in a queue of messages to be sent. The actuallySendMessage() message must be implemented with the code to actually send the message. The motivation behind this class is to use the message queue to limit the rate at which messages are sent so that the AIM bot does not get kicked offline.

Author:
mbolin

Nested Class Summary
protected  class AbstractMessageProxy.Message
           
protected  class AbstractMessageProxy.MessageTask
           
 
Field Summary
protected  LinkedList messageQueue
          The queue of messages to be sent.
protected  long period
           
protected  Timer timer
           
 
Constructor Summary
AbstractMessageProxy(long period)
           
 
Method Summary
abstract  void actuallySendMessage(Buddy buddy, String message)
          Must be overridden to encode how to send the message through the AIM library being used.
abstract  void addBuddy(Buddy buddy)
          adds the buddy to the list of the buddies who can be messaged
 void sendMessage(Buddy buddy, String message)
          Adds the message to the end of the queue of messages to be sent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messageQueue

protected LinkedList messageQueue
The queue of messages to be sent.


period

protected long period

timer

protected Timer timer
Constructor Detail

AbstractMessageProxy

public AbstractMessageProxy(long period)
Parameters:
period - number of milliseconds between messages sent
Method Detail

addBuddy

public abstract void addBuddy(Buddy buddy)
Description copied from interface: MessageProxy
adds the buddy to the list of the buddies who can be messaged

Specified by:
addBuddy in interface MessageProxy

sendMessage

public void sendMessage(Buddy buddy,
                        String message)
Adds the message to the end of the queue of messages to be sent.

Specified by:
sendMessage in interface MessageProxy

actuallySendMessage

public abstract void actuallySendMessage(Buddy buddy,
                                         String message)
Must be overridden to encode how to send the message through the AIM library being used.