swpchat.client
Class ReceiverServerConnection

java.lang.Object
  |
  +--swpchat.client.ServerConnection
        |
        +--swpchat.client.ReceiverServerConnection
All Implemented Interfaces:
ChatTokens, ControlTokens, ProtocolTokens, ReceiverClient, SenderReceiverTokens

public class ReceiverServerConnection
extends ServerConnection
implements ReceiverClient

Class for receiver connection to the server.


Field Summary
private  ClientControls clientControls
           
private static java.lang.String CLS
           
private  boolean connected
           
private  MessageReceiver messageReceiver
           
private  java.io.BufferedWriter oStream
           
private  java.net.Socket socket
           
private  ChatStreamTokenizer tokenizer
           
private  java.util.Vector tokenlist
           
 
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
ReceiverServerConnection(ClientControls clientControls)
          Constructor.
 
Method Summary
 void connect(java.lang.String servername, java.lang.String sessionKey)
          Connects to the given server with the given nickname.
 void disconnect()
          Disconnect from the server.
 boolean isConnected()
          Checks wether the client is connected.
 void join(java.lang.String sessionKey, java.lang.String channelName)
          join specified channel
 void leave(java.lang.String channelName)
          leave the specified channel
 
Methods inherited from class swpchat.client.ServerConnection
isEmotion, isEmotionReceive, isEmotionReply, isJoinReply, isLeaveReply, isLoginReply, isLogoutReply, isMemberInfo, isNegativeRequestUserInfoReply, isNegativeSendUserInfoReply, isNewChannel, isNewChannelReply, isNotification, isPlay, isPlayReply, isPositiveRequestUserInfoReply, isPositiveSendUserInfoReply, isReceive, isReceiveUserInfo, isRemoveChannel, isRemoveChannelReply, isRenameChannel, isRenameChannelReply, isRequestIPAddress, isRequestIPAddressReply, isSendReply, isSendTelephoneRequest, isSendTelephoneRequestReply, isSetNickReply, isSetSessionKeyReply, isSetTopicReply, isShipReceive, isShipReply, isTopicChanged, isWhisperReply, isWhispreceive, readReply, reply, 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

socket

private java.net.Socket socket

oStream

private java.io.BufferedWriter oStream

messageReceiver

private MessageReceiver messageReceiver

tokenizer

private ChatStreamTokenizer tokenizer

tokenlist

private java.util.Vector tokenlist

clientControls

private ClientControls clientControls

connected

private boolean connected
Constructor Detail

ReceiverServerConnection

public ReceiverServerConnection(ClientControls clientControls)
Constructor. Used to set client controls.
Method Detail

connect

public void connect(java.lang.String servername,
                    java.lang.String sessionKey)
             throws ServiceRefusedException,
                    TimeoutException,
                    java.io.IOException
Connects to the given server with the given nickname.
Specified by:
connect in interface ReceiverClient
Parameters:
servername - The name of a spChatServer host, in a notation accepted by Socket.Socket(String,int).
sessionkey - The identification key for this session
Throws:
ServiceRefusedException - If the server rejected logging in. Generally not being able to open the socket produces some java.net exception.
TimeoutException - If the Server did not react within a certain timeout.
java.io.IOException - For problems in lower layers.

join

public void join(java.lang.String sessionKey,
                 java.lang.String channelName)
          throws ServiceRefusedException,
                 TimeoutException,
                 NotConnectedException,
                 java.io.IOException
join specified channel
Specified by:
join in interface ReceiverClient
Parameters:
sessionKey - that identifies the client
String - the Channel to join

leave

public void leave(java.lang.String channelName)
           throws ServiceRefusedException,
                  TimeoutException,
                  NotConnectedException,
                  java.io.IOException
leave the specified channel
Specified by:
leave in interface ReceiverClient
Parameters:
strChannel - the channel to left

disconnect

public void disconnect()
                throws java.io.IOException
Disconnect from the server. As a receiver is not really disconnected, this simply handles an internal state.
Specified by:
disconnect in interface ReceiverClient
Throws:
java.io.IOException - If something broken.

isConnected

public boolean isConnected()
Checks wether the client is connected. Currently, this checks only the internal state of the client, not wether the connection is operational.
Specified by:
isConnected in interface ReceiverClient
Returns:
true If the client (thinks it) is connected to a server.