swpchat.server
Class SenderProtocolHandler

java.lang.Object
  |
  +--swpchat.server.ProtocolHandler
        |
        +--swpchat.server.SenderProtocolHandler
All Implemented Interfaces:
ChatTokens, ControlTokens, NotificationTokens, SenderReceiverTokens, SenderServer

public class SenderProtocolHandler
extends ProtocolHandler
implements SenderServer, NotificationTokens

Used for communication with the client, the server part of the chat protocol


Field Summary
private  ChannelCollection channelCollection
           
private  java.net.Socket clientSocket
           
private static java.lang.String CLS
           
private  boolean connected
           
private  ConnectedClientCollection connectedClientCollection
           
private  NickNameCollection nickCollection
           
private  java.lang.String nickName
           
private  java.lang.String sessionKey
           
private  java.lang.String tmpNickName
           
private  boolean tmpShipStatus
           
private  java.lang.String tmpTopic
           
private  UserInfoHandler userInfoHandler
           
 
Fields inherited from interface swpchat.protocol.NotificationTokens
STR_STATE_JOINED, STR_STATE_LEFT, STR_STATE_OFFLINE, STR_STATE_ONLINE
 
Fields inherited from interface swpchat.protocol.ChatTokens
CHAR_ARG_SEP, CHAR_MSG_END, CHAR_MSG_EOL, CHAR_QUOTE, CHAR_STRING_DELIMITER, STR_ARG_SEP, STR_AUTHORIZE, STR_MSG_END, STR_MSG_EOL, STR_NEG_ARG, STR_NEGATIVE, STR_POS_ARG, STR_POSITIVE, STR_QUOTE, STR_REPLY, STR_STRING_DELIMITER, STR_WAIT
 
Fields inherited from interface swpchat.protocol.SenderReceiverTokens
STR_JOIN, STR_JOINPASSWD, STR_LEAVE, STR_OFF, STR_ON, STR_PLAY, STR_PLAY_BEGIN, STR_PLAY_RE_BEGIN, STR_RECEIVE, STR_RECEIVE_BEGIN, STR_RECEIVE_USERINFO, STR_REQUEST_USERINFO, STR_SEND, STR_SEND_BEGIN, STR_SEND_RE_BEGIN, STR_SETTOPIC, STR_SETTOPIC_BEGIN, STR_SHIP, STR_SHIP_BEGIN, STR_TOPICCHANGED, STR_WHISPER, STR_WHISPRECEIVE
 
Fields inherited from interface swpchat.protocol.ControlTokens
STR_EMOTION, STR_LOGIN, STR_LOGIN_BEGIN, STR_LOGIN_RE_BEGIN, STR_LOGOUT, STR_LOGOUT_BEGIN, STR_LOGOUT_RE_BEGIN, STR_MEMBER, STR_MEMBER_BEGIN, STR_MEMBER_INFO, STR_MEMBER_JOIN, STR_MEMBER_LEAVE, STR_MEMBER_SHIP, STR_NEW_CHANNEL, STR_NOTIFICATION, STR_NOTIFICATION_BEGIN, STR_NOTIFY_REQUEST, STR_REMOVE_CHANNEL, STR_RENAME_CHANNEL, STR_REQUEST_IP, STR_REQUST_IP_RE_BEGIN, STR_SEND_USERINFO, STR_SET_NICK, STR_SET_NICK_BEGIN, STR_SET_NICK_RE_BEGIN, STR_SET_SESSIONKEY, STR_STOP_NOTIFICATION, STR_TELEPHONE_REQUEST
 
Constructor Summary
SenderProtocolHandler(ChannelCollection channelCollection, NickNameCollection nickCollection, ConnectedClientCollection connectedClientCollection)
          Constructor
 
Method Summary
 void disconnect()
           
 java.lang.String getNick()
           
 void serve(java.net.Socket clientSocket, ClientConnection clientConnection, java.io.InputStream inputStream)
          serves the client: parses commands from the client and sends appropiate replies (protocol violations are ignored for now)
 
Methods inherited from class swpchat.server.ProtocolHandler
isEmotion, isJoin, isJoinPasswd, isLeave, isLogin, isLogout, isMemberRequest, isNewChannel, isNewChannelReply, isNotificationRequest, isPlay, isPutShip, isRemoveChannel, isRemoveChannelReply, isRenameChannel, isRenameChannelReply, isRequestIPAddress, isRequestIPAddressReply, isRequestUserInfo, isSend, isSendTelephoneRequest, isSendTelephoneRequestReply, isSendUserInfo, isSetNick, isSetSessionKey, isSetTopic, isStopNotification, isWhisper, readCommand, reply, send, send, send, send, send, writeLine
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

CLS

private static final java.lang.String CLS

channelCollection

private ChannelCollection channelCollection

nickCollection

private NickNameCollection nickCollection

connectedClientCollection

private ConnectedClientCollection connectedClientCollection

sessionKey

private java.lang.String sessionKey

nickName

private java.lang.String nickName

tmpNickName

private java.lang.String tmpNickName

tmpTopic

private java.lang.String tmpTopic

tmpShipStatus

private boolean tmpShipStatus

clientSocket

private java.net.Socket clientSocket

connected

private boolean connected

userInfoHandler

private UserInfoHandler userInfoHandler
Constructor Detail

SenderProtocolHandler

public SenderProtocolHandler(ChannelCollection channelCollection,
                             NickNameCollection nickCollection,
                             ConnectedClientCollection connectedClientCollection)
Constructor
Parameters:
channelCollection, - Collection of all possible Channels
nickCollection, - Collection of all Nicknames
connectedClientCollection, - Collection of all connected Clients
Method Detail

serve

public void serve(java.net.Socket clientSocket,
                  ClientConnection clientConnection,
                  java.io.InputStream inputStream)
           throws TimeoutException,
                  java.io.IOException,
                  java.security.InvalidParameterException
serves the client: parses commands from the client and sends appropiate replies (protocol violations are ignored for now)
Specified by:
serve in interface SenderServer
Overrides:
serve in class ProtocolHandler
Parameters:
clientSocket - Socket used for communication between client and server .
Throws:
TimeoutException - thrown if connection to the client is lost or too slow.
java.io.IOException - thrown for any I/O error.
java.security.InvalidParameterException - possibly useful

disconnect

public void disconnect()
Overrides:
disconnect in class ProtocolHandler

getNick

public java.lang.String getNick()
Specified by:
getNick in interface SenderServer