tasks
Class ChatServer

java.lang.Object
  extended by tasks.ChatServer

public class ChatServer
extends java.lang.Object

ChatServer provides chat server logic. In order to create a chat server, you just need to instantiate one of these classes and than call processMessage whenever you need to process a chat message. This object will parse it and modifying any state that it needs to.

Author:
sean

Field Summary
static java.lang.String ERR_NICKNAMEINUSE
           
static java.lang.String ERR_NOLOGIN
           
static java.lang.String ERR_NOSUCHCHANNEL
           
static java.lang.String ERR_NOSUCHNICK
           
static java.lang.String ERR_NOTONCHANNEL
           
static java.lang.String ERR_TOOMANYCHANNELS
           
static java.lang.String ERR_UNKNOWNCOMMAND
           
static java.lang.String RPL_ENDOFNAMES
           
static java.lang.String RPL_LIST
           
static java.lang.String RPL_LISTEND
           
static java.lang.String RPL_NAMREPLY
           
static java.lang.String RPL_WELCOME
           
 
Constructor Summary
ChatServer(ChatServerNetwork networkAccess)
           
 
Method Summary
 java.util.List<java.lang.String> getStateAsMessages()
          Return a list of messages that can be used to recreate the internal state of the chat server.
 void processMessage(java.nio.channels.SelectionKey key, java.lang.String message, boolean fromClient)
          Process a message that was sent by the SelectionKey key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERR_UNKNOWNCOMMAND

public static java.lang.String ERR_UNKNOWNCOMMAND

ERR_NICKNAMEINUSE

public static java.lang.String ERR_NICKNAMEINUSE

ERR_TOOMANYCHANNELS

public static java.lang.String ERR_TOOMANYCHANNELS

ERR_NOLOGIN

public static java.lang.String ERR_NOLOGIN

ERR_NOSUCHCHANNEL

public static java.lang.String ERR_NOSUCHCHANNEL

ERR_NOTONCHANNEL

public static java.lang.String ERR_NOTONCHANNEL

ERR_NOSUCHNICK

public static java.lang.String ERR_NOSUCHNICK

RPL_WELCOME

public static java.lang.String RPL_WELCOME

RPL_LIST

public static java.lang.String RPL_LIST

RPL_LISTEND

public static java.lang.String RPL_LISTEND

RPL_NAMREPLY

public static java.lang.String RPL_NAMREPLY

RPL_ENDOFNAMES

public static java.lang.String RPL_ENDOFNAMES
Constructor Detail

ChatServer

public ChatServer(ChatServerNetwork networkAccess)
Method Detail

processMessage

public void processMessage(java.nio.channels.SelectionKey key,
                           java.lang.String message,
                           boolean fromClient)
                    throws java.lang.Exception
Process a message that was sent by the SelectionKey key. fromClient is true/false depending on whether or not the message was from a directly connect client. Alternatively, this can also process messages from the router.

Parameters:
key -
message -
fromClient -
Throws:
java.lang.Exception

getStateAsMessages

public java.util.List<java.lang.String> getStateAsMessages()
Return a list of messages that can be used to recreate the internal state of the chat server.

Returns: