talx x1.0.5

talx.model.filters
Class CommandFilter

java.lang.Object
  extended bytalx.model.filters.ReceiverFilterAdapter
      extended bytalx.model.filters.CommandFilter
All Implemented Interfaces:
ControllerConstants, java.util.EventListener, ReceiverFilter, ReceiverFilterListener, TALFeature

public class CommandFilter
extends ReceiverFilterAdapter
implements ControllerConstants

Searches incoming messages for test commands and game moves.


Field Summary
static java.text.SimpleDateFormat LOG_DATE_FORMAT
           
 
Fields inherited from interface talx.controller.ControllerConstants
EXIT_COMMAND, FILE_ATTACHMENTS_KEY, ILLEGAL_ACTION_COMMAND, LOGOUT_COMMAND, MAIL_COUNT_CHANGED_COMMAND, REMOTE_GAME_COMMAND, SAVE_COMMAND, STOP_COMMAND, TEST_COMMAND
 
Constructor Summary
CommandFilter(GameManager gm, Settings s, java.lang.String param)
           
 
Method Summary
protected  boolean filterMessage(javax.mail.internet.MimeMessage msg)
          Filters messages containing CPIS commands and game moves.
 javax.mail.internet.MimeMessage getTestResults(java.util.Date timestamp)
           
 
Methods inherited from class talx.model.filters.ReceiverFilterAdapter
addFilterListener, filterActivated, fireFilterActivated, fireNewMailEvent, newMailArrived, release, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG_DATE_FORMAT

public static final java.text.SimpleDateFormat LOG_DATE_FORMAT
Constructor Detail

CommandFilter

public CommandFilter(GameManager gm,
                     Settings s,
                     java.lang.String param)
Parameters:
param - A set of key=value pairs that describe the handling of commands. This are:
Throws:
java.lang.NullPointerException - if the required keys are not present in param.
Method Detail

filterMessage

protected boolean filterMessage(javax.mail.internet.MimeMessage msg)
Filters messages containing CPIS commands and game moves.

Test Commands

Any message containing a test message header will be filtered. Another message, appearing to come from tech is placed in the pipe, saying that the test succeeded.

Game Moves

Any messages that contain game moves are moved to the filtered pipe. This filter determines game moves by looking for a header matching the GameManager.MOVE_MESSAGE_HEADER. If that header is found, the message is interpreted as a move and this filter tries to interpret the body as a serialized GameMemento. This process will fail if the message is a multipart message or if the single part was not created as a ObjectOutputStream and had a single GameMemento written to it. If the process fails, the reason is logged and the move is dropped. The sender is not notified.

Important Note: Once the filter sees the proper header, the message is filtered, whether or not a GameState can successfully be extracted.

Specified by:
filterMessage in class ReceiverFilterAdapter
Parameters:
msg - The message to be filtered by this method.
Returns:
true if the message should be passed along, false if the message should be dropped.
See Also:
CPIS Command Syntax

getTestResults

public javax.mail.internet.MimeMessage getTestResults(java.util.Date timestamp)
                                               throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

talx x1.0.5

© 2001-2005 University of Oregon.
Eugene OR 97403, U.S.A. All Rights Reserved.