|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--swpchat.client.ServerConnection | +--swpchat.client.ControlConnection
The controler connection to the server. This class handles all net traffic that is related to administrate the chat session, such as logging in and out, setting the nickname, adding and removing channels...
Field Summary | |
private java.io.BufferedWriter |
bufWriter
|
private ClientControls |
clientControls
|
private static java.lang.String |
CLS
|
private boolean |
connected
|
private ControlReceiver |
controlReceiver
|
private java.lang.String |
sessionKey
|
private java.net.Socket |
socket
|
private ChatStreamTokenizer |
tokenizer
|
private java.util.Vector |
tokenlist
|
private java.lang.String |
True_Bool
|
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.FileTransferTokens |
STR_SEND_FILE_REQUEST, STR_SEND_FILE_REQUEST_BEGIN, STR_SET_FILENAME, STR_SET_FILENAME_BEGIN, STR_SET_FILESIZE, STR_SET_FILESIZE_BEGIN |
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.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 | |
ControlConnection(ClientControls clientControls)
Constructor. |
Method Summary | |
void |
changeNick(java.lang.String sessionKey,
java.lang.String newNick)
Change the nickname. |
private void |
changeNickEvenIfUnconnected(java.lang.String sessionKey,
java.lang.String newNick)
Change the nickname without checking connectedness. |
void |
connect(java.lang.String servername,
java.lang.String nickname)
Connect to the server. |
void |
createNewChannel(java.lang.String name,
java.lang.String sendPasswd,
java.lang.String recvPasswd)
sends a create new channel request to the server. |
void |
disconnect()
Disconnect from the server. |
java.lang.String |
getIPAddress(java.lang.String nickname)
requestIPAddress from the server |
java.lang.String |
getSessionKey()
Gets the actual session key and returns it. |
void |
handleNormalReceiving(java.util.Vector tokenlist)
Handles all received messages a receiver control connection would handle, such as newChannel or removeChannel. |
boolean |
isConnected()
Checks if the control unit is connected to the server. |
void |
memberRequest(java.lang.String channel,
java.lang.String reason)
Used to pass the Member Message to the Server,showing the readiness to receive Member Info Messages |
void |
notificationRequest(java.lang.String nick)
Send a notificationRequest to the server |
void |
removeChannel(java.lang.String name)
removes an existing channel, but not used yet. |
void |
renameChannel(java.lang.String oldname,
java.lang.String newname)
renames an existing channel, but not used yet. |
void |
sendContactList()
|
java.lang.String |
sendTelephoneRequest(java.lang.String partner,
java.lang.String reason)
Send telephonerequest to the server. |
void |
sendUserInfo(java.lang.String strUserInfo)
sends a "sendUserInfo" - command to the server with serveral userInfos serialized to a string |
void |
stopNotification(java.lang.String nick)
Send a StopNotification to the server |
private java.lang.Boolean |
StringToBool(java.lang.String string)
|
Methods inherited from class java.lang.Object |
|
Field Detail |
private static final java.lang.String CLS
private java.net.Socket socket
private java.io.BufferedWriter bufWriter
private ChatStreamTokenizer tokenizer
private java.util.Vector tokenlist
private ControlReceiver controlReceiver
private ClientControls clientControls
private java.lang.String sessionKey
private boolean connected
private final java.lang.String True_Bool
Constructor Detail |
public ControlConnection(ClientControls clientControls)
Method Detail |
public void connect(java.lang.String servername, java.lang.String nickname) throws ServiceRefusedException, TimeoutException, java.io.IOException
connect
in interface ControlClient
servername
- The server to connect to.nickname
- The user's choosen nickname.ServiceRefusedException
- If the server refused the login request.TimeoutException
- If the server does not send the
receipt within a certain timeout.java.io.IOException
- For problems in lower layers.public void changeNick(java.lang.String sessionKey, java.lang.String newNick) throws ServiceRefusedException, NotConnectedException, TimeoutException, java.io.IOException, java.net.ProtocolException
changeNick
in interface ControlClient
ServiceRefusedException
- If the nickname could not be changed.NotConnectedException
- The client is not connected to
the server.TimeoutException
- If the server does not send the
receipt within a certain timeout.java.io.IOException
- For problems in lower layers.java.net.ProtocolException
- If receiving an unexpected answer.private void changeNickEvenIfUnconnected(java.lang.String sessionKey, java.lang.String newNick) throws ServiceRefusedException, TimeoutException, java.io.IOException, java.net.ProtocolException
public java.lang.String getIPAddress(java.lang.String nickname) throws ServiceRefusedException, TimeoutException, java.io.IOException, java.net.ProtocolException
nickname
- identyfies the owner of the requested IPAddresspublic java.lang.String sendTelephoneRequest(java.lang.String partner, java.lang.String reason) throws ServiceRefusedException, TimeoutException, java.io.IOException, java.net.ProtocolException
partner
- the nickname of the partner who is desired to be talked withreason
- the reason, the desired partner gets to seeServiceRefusedException
- If the server rejected
the send request.TimeoutException
- If the server does not send the
receipt within a certain timeout.java.io.IOException
- For problems in lower layers.java.net.ProtocolException
- For problems with the protocol.public void disconnect() throws NotConnectedException, java.io.IOException, TimeoutException, java.net.ProtocolException
disconnect
in interface ControlClient
NotConnectedException
- If the client has not been
connected in the first place.java.io.IOException
- For problems in lower layers. The
client is disconnected nonetheless.TimeoutException
- If the server does not respond
within the timeout.java.net.ProtocolException
- If receiving an unexpected answer.public void createNewChannel(java.lang.String name, java.lang.String sendPasswd, java.lang.String recvPasswd) throws NotConnectedException, java.io.IOException, TimeoutException, ServiceRefusedException
createNewChannel
in interface ControlClient
name
- The channel name.NotConnectedException
- if we are not connected to the server.TimeoutException
- if the server does not respond within the timeoutServiceRefusedException
- if the server refuses creating a new channeljava.io.IOException
- on IO propblems in lower layerspublic void renameChannel(java.lang.String oldname, java.lang.String newname) throws NotConnectedException, java.io.IOException, TimeoutException, java.net.ProtocolException, ServiceRefusedException
renameChannel
in interface ControlClient
name
- The channel name.NotConnectedException
- if we are not connected to the server.TimeoutException
- if the server does not respond within the timeoutServiceRefusedException
- if the server refuses creating a new channeljava.io.IOException
- on IO propblems in lower layersjava.net.ProtocolException
- if we receive an unexpected answer.public void removeChannel(java.lang.String name) throws NotConnectedException, java.io.IOException, TimeoutException, java.net.ProtocolException, ServiceRefusedException
removeChannel
in interface ControlClient
name
- The channel name.NotConnectedException
- if we are not connected to the server.TimeoutException
- if the server does not respond within the timeoutServiceRefusedException
- if the server refuses creating a new channeljava.io.IOException
- on IO propblems in lower layersjava.net.ProtocolException
- if we receive an unexpected answer.public void sendUserInfo(java.lang.String strUserInfo) throws NotConnectedException, java.io.IOException, TimeoutException, java.net.ProtocolException, ServiceRefusedException
strUserInfo
- user info string of this shape: firstname":"Rene":"lastname":"Woerzbergerpublic void handleNormalReceiving(java.util.Vector tokenlist) throws java.io.IOException, java.net.ProtocolException
handleNormalReceiving
in interface ControlClient
tokenlist
- The tokenlist got from InputStream.private java.lang.Boolean StringToBool(java.lang.String string)
public void memberRequest(java.lang.String channel, java.lang.String reason) throws ServiceRefusedException, TimeoutException, java.io.IOException
channel
- the Channel we are joined inreason
- of MemberRequestpublic void sendContactList() throws TimeoutException, java.io.IOException
public void notificationRequest(java.lang.String nick) throws TimeoutException, java.io.IOException
nick
- the user you want to be notified of.TimeoutException
- thrown if time exceedsjava.io.IOException
- Error occured in lower layers.public void stopNotification(java.lang.String nick) throws TimeoutException, java.io.IOException
nick
- the user you donīt want to be notified of anymore.TimeoutException
- thrown if time exceedsjava.io.IOException
- Error occured in lower layers.public boolean isConnected()
isConnected
in interface ControlClient
public java.lang.String getSessionKey()
getSessionKey
in interface ControlClient
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |