tasks
Class ChatServer
java.lang.Object
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
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 |
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
ChatServer
public ChatServer(ChatServerNetwork networkAccess)
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: