swpchat.client
Class ServerConnection

java.lang.Object
  |
  +--swpchat.client.ServerConnection
All Implemented Interfaces:
ChatTokens, ControlTokens, ProtocolTokens, SenderReceiverTokens
Direct Known Subclasses:
ControlConnection, FileConnection, ReceiverServerConnection, SenderServerConnection

public class ServerConnection
extends java.lang.Object
implements SenderReceiverTokens, ControlTokens, ProtocolTokens


Field Summary
private static java.lang.String CLS
           
 
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.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.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
 
Fields inherited from interface swpchat.protocol.ProtocolTokens
STR_CONTROL, STR_CONTROL_PROTOCOL_ID, STR_FILE_SEND, STR_FILE_SEND_PROTOCOL_ID, STR_PROTOCOL, STR_PROTOCOL_ID_BEGIN, STR_RECEIVER, STR_RECEIVER_PROTOCOL_ID, STR_SENDER, STR_SENDER_PROTOCOL_ID
 
Constructor Summary
ServerConnection()
           
 
Method Summary
protected static boolean isEmotion(java.util.Vector tokenlist)
           
protected static boolean isEmotionReceive(java.util.Vector tokenlist)
           
protected static boolean isEmotionReply(java.util.Vector tokenlist)
           
protected static boolean isJoinReply(java.util.Vector tokenlist)
           
protected static boolean isLeaveReply(java.util.Vector tokenlist)
           
protected static boolean isLoginReply(java.util.Vector tokenlist)
          Returns true, iff the tokenlist contains a valid login command.
protected static boolean isLogoutReply(java.util.Vector tokenlist)
          Returns true, iff the tokenlist contains a valid logout command.
protected static boolean isMemberInfo(java.util.Vector tokenlist)
           
protected static boolean isNegativeRequestUserInfoReply(java.util.Vector tokenlist)
           
protected static boolean isNegativeSendUserInfoReply(java.util.Vector tokenlist)
           
protected static boolean isNewChannel(java.util.Vector tokenlist)
           
protected static boolean isNewChannelReply(java.util.Vector tokenlist)
           
protected static boolean isNotification(java.util.Vector tokenlist)
           
protected static boolean isPlay(java.util.Vector tokenlist)
           
protected static boolean isPlayReply(java.util.Vector tokenlist)
           
protected static boolean isPositiveRequestUserInfoReply(java.util.Vector tokenlist)
           
protected static boolean isPositiveSendUserInfoReply(java.util.Vector tokenlist)
           
protected static boolean isReceive(java.util.Vector tokenlist)
          Returns true, iff the tokenlist contains a valid send command.
protected static boolean isReceiveUserInfo(java.util.Vector tokenlist)
           
protected static boolean isRemoveChannel(java.util.Vector tokenlist)
           
protected static boolean isRemoveChannelReply(java.util.Vector tokenlist)
           
protected static boolean isRenameChannel(java.util.Vector tokenlist)
           
protected static boolean isRenameChannelReply(java.util.Vector tokenlist)
           
protected static boolean isRequestIPAddress(java.util.Vector tokenlist)
          true, iff tokenlist contains valid requestIPAddress command.
protected static boolean isRequestIPAddressReply(java.util.Vector tokenlist)
          true, iff tokenlist contains valid requestIPAddress reply.
protected static boolean isSendReply(java.util.Vector tokenlist)
           
protected static boolean isSendTelephoneRequest(java.util.Vector tokenlist)
          true, iff tokenlist contains valid sendTelephoneRequest command.
protected static boolean isSendTelephoneRequestReply(java.util.Vector tokenlist)
          true, iff tokenlist contains valid telephonerquestreply reply.
protected static boolean isSetNickReply(java.util.Vector tokenlist)
          Returns true, iff the tokenlist contains a valid setNick command.
protected static boolean isSetSessionKeyReply(java.util.Vector tokenlist)
          Returns true, iff the tokenlist contains a valid setNick command.
protected static boolean isSetTopicReply(java.util.Vector tokenlist)
           
protected static boolean isShipReceive(java.util.Vector tokenlist)
          Returns true, iff the tokenlist contains a valid shipReceive command.
protected static boolean isShipReply(java.util.Vector tokenlist)
          Returns true, iff the tokenlist contains a valid shipReply command.
protected static boolean isTopicChanged(java.util.Vector tokenlist)
           
protected static boolean isWhisperReply(java.util.Vector tokenlist)
           
protected static boolean isWhispreceive(java.util.Vector tokenlist)
           
protected static java.util.Vector readReply(ChatStreamTokenizer tokenizer, java.net.Socket sourceSocket)
          Fetch one command from the inputStream.
protected static void reply(java.io.BufferedWriter ostream, java.lang.String command, java.lang.String information)
           
protected static void send(java.io.BufferedWriter ostream, java.lang.String command)
           
protected static void send(java.io.BufferedWriter ostream, java.lang.String command, java.lang.String information)
           
protected static void send(java.io.BufferedWriter ostream, java.lang.String command, java.lang.String information1, java.lang.String information2)
          Generate an answer for a given command, much shorter than writing ostream.write....
protected static void send(java.io.BufferedWriter ostream, java.lang.String command, java.lang.String information1, java.lang.String information2, java.lang.String information3)
          Generate an answer for a given command Added especially for the Whispermessage.
private static void writeLine(java.io.BufferedWriter ostream, java.lang.String message)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

CLS

private static java.lang.String CLS
Constructor Detail

ServerConnection

public ServerConnection()
Method Detail

isSetNickReply

protected static boolean isSetNickReply(java.util.Vector tokenlist)
Returns true, iff the tokenlist contains a valid setNick command.

isSetSessionKeyReply

protected static boolean isSetSessionKeyReply(java.util.Vector tokenlist)
Returns true, iff the tokenlist contains a valid setNick command.

isLoginReply

protected static boolean isLoginReply(java.util.Vector tokenlist)
Returns true, iff the tokenlist contains a valid login command.

isLogoutReply

protected static boolean isLogoutReply(java.util.Vector tokenlist)
Returns true, iff the tokenlist contains a valid logout command.

isJoinReply

protected static boolean isJoinReply(java.util.Vector tokenlist)

isSetTopicReply

protected static boolean isSetTopicReply(java.util.Vector tokenlist)

isTopicChanged

protected static boolean isTopicChanged(java.util.Vector tokenlist)

isLeaveReply

protected static boolean isLeaveReply(java.util.Vector tokenlist)

isSendReply

protected static boolean isSendReply(java.util.Vector tokenlist)

isWhisperReply

protected static boolean isWhisperReply(java.util.Vector tokenlist)

isEmotionReply

protected static boolean isEmotionReply(java.util.Vector tokenlist)

isPlayReply

protected static boolean isPlayReply(java.util.Vector tokenlist)

isShipReply

protected static boolean isShipReply(java.util.Vector tokenlist)
Returns true, iff the tokenlist contains a valid shipReply command.

isEmotion

protected static boolean isEmotion(java.util.Vector tokenlist)

isReceive

protected static boolean isReceive(java.util.Vector tokenlist)
Returns true, iff the tokenlist contains a valid send command.

isShipReceive

protected static boolean isShipReceive(java.util.Vector tokenlist)
Returns true, iff the tokenlist contains a valid shipReceive command.

isWhispreceive

protected static boolean isWhispreceive(java.util.Vector tokenlist)

isEmotionReceive

protected static boolean isEmotionReceive(java.util.Vector tokenlist)

isPlay

protected static boolean isPlay(java.util.Vector tokenlist)

isNewChannelReply

protected static boolean isNewChannelReply(java.util.Vector tokenlist)

isRemoveChannelReply

protected static boolean isRemoveChannelReply(java.util.Vector tokenlist)

isRenameChannelReply

protected static boolean isRenameChannelReply(java.util.Vector tokenlist)

isNewChannel

protected static boolean isNewChannel(java.util.Vector tokenlist)

isRemoveChannel

protected static boolean isRemoveChannel(java.util.Vector tokenlist)

isRenameChannel

protected static boolean isRenameChannel(java.util.Vector tokenlist)

isPositiveSendUserInfoReply

protected static boolean isPositiveSendUserInfoReply(java.util.Vector tokenlist)

isNegativeSendUserInfoReply

protected static boolean isNegativeSendUserInfoReply(java.util.Vector tokenlist)

isPositiveRequestUserInfoReply

protected static boolean isPositiveRequestUserInfoReply(java.util.Vector tokenlist)

isNegativeRequestUserInfoReply

protected static boolean isNegativeRequestUserInfoReply(java.util.Vector tokenlist)

isReceiveUserInfo

protected static boolean isReceiveUserInfo(java.util.Vector tokenlist)

isSendTelephoneRequest

protected static boolean isSendTelephoneRequest(java.util.Vector tokenlist)
true, iff tokenlist contains valid sendTelephoneRequest command.
Parameters:
tokenlist - the tokenlist to be analysed
Returns:
true, iff it is a valid sendFileRequest command

isSendTelephoneRequestReply

protected static boolean isSendTelephoneRequestReply(java.util.Vector tokenlist)
true, iff tokenlist contains valid telephonerquestreply reply.
Parameters:
tokenlist - the tokenlist to be analysed
Returns:
true, iff it is a valid requestUserInfo command

isRequestIPAddress

protected static boolean isRequestIPAddress(java.util.Vector tokenlist)
true, iff tokenlist contains valid requestIPAddress command.
Parameters:
tokenlist - the tokenlist to be analysed
Returns:
true, iff it is a valid requestUserInfo command

isRequestIPAddressReply

protected static boolean isRequestIPAddressReply(java.util.Vector tokenlist)
true, iff tokenlist contains valid requestIPAddress reply.
Parameters:
tokenlist - the tokenlist to be analysed
Returns:
true, iff it is a valid requestUserInfo command

isMemberInfo

protected static boolean isMemberInfo(java.util.Vector tokenlist)

isNotification

protected static boolean isNotification(java.util.Vector tokenlist)

writeLine

private static void writeLine(java.io.BufferedWriter ostream,
                              java.lang.String message)
                       throws java.io.IOException

reply

protected static void reply(java.io.BufferedWriter ostream,
                            java.lang.String command,
                            java.lang.String information)
                     throws java.io.IOException

send

protected static void send(java.io.BufferedWriter ostream,
                           java.lang.String command)
                    throws java.io.IOException

send

protected static void send(java.io.BufferedWriter ostream,
                           java.lang.String command,
                           java.lang.String information)
                    throws java.io.IOException

send

protected static void send(java.io.BufferedWriter ostream,
                           java.lang.String command,
                           java.lang.String information1,
                           java.lang.String information2)
                    throws java.io.IOException
Generate an answer for a given command, much shorter than writing ostream.write.... several times.

send

protected static void send(java.io.BufferedWriter ostream,
                           java.lang.String command,
                           java.lang.String information1,
                           java.lang.String information2,
                           java.lang.String information3)
                    throws java.io.IOException
Generate an answer for a given command Added especially for the Whispermessage.

readReply

protected static java.util.Vector readReply(ChatStreamTokenizer tokenizer,
                                            java.net.Socket sourceSocket)
                                     throws TimeoutException,
                                            java.io.IOException
Fetch one command from the inputStream. readReply does not only read Reply Messages, but also all other messages, that come from the server.