|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--swpchat.client.ServerConnection | +--swpchat.client.SenderServerConnection
Class for sender communication to the server.
Field Summary | |
private ClientControls |
clientControls
|
(package private) static java.lang.String |
CLS
|
(package private) boolean |
connected
|
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.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 | |
SenderServerConnection(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. |
void |
emotion(java.lang.String channelName,
java.lang.String target,
java.lang.String emotion)
Emotion message to 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 |
void |
play(java.lang.String channelName,
java.lang.String audioKey)
Make other clients play a sound file. |
void |
requestUserInfo(java.lang.String nickname)
sends a user info request |
void |
send(java.lang.String channelName,
java.lang.String text)
Send media to the server. |
void |
setTopic(java.lang.String channelName,
java.lang.String topic)
Set topic for a channel. |
void |
ship(java.lang.String nick,
java.lang.String status,
ShipWindow shipWindow)
Ship media to the server. |
void |
whisper(java.lang.String channelName,
java.lang.String receiver,
java.lang.String text)
Whisper message to the server. |
Methods inherited from class java.lang.Object |
|
Field Detail |
static final java.lang.String CLS
private java.net.Socket socket
private java.io.BufferedWriter oStream
private ChatStreamTokenizer tokenizer
private java.util.Vector tokenlist
private ClientControls clientControls
boolean connected
Constructor Detail |
public SenderServerConnection(ClientControls clientControls)
Method Detail |
public void connect(java.lang.String servername, java.lang.String sessionKey) throws ServiceRefusedException, TimeoutException, java.io.IOException
connect
in interface SenderClient
servername
- The name of a spChatServer host, in a
notation accepted by Socket.Socket(String,int)
.nickname
- The desired nickname.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.public void join(java.lang.String sessionKey, java.lang.String channelName) throws ServiceRefusedException, TimeoutException, NotConnectedException, java.io.IOException
join
in interface SenderClient
sessionKey
- that identifies the clientString
- the Channel to joinpublic void leave(java.lang.String channelName) throws ServiceRefusedException, TimeoutException, NotConnectedException, java.io.IOException
leave
in interface SenderClient
strChannel
- the channel to leftpublic void send(java.lang.String channelName, java.lang.String text) throws ServiceRefusedException, NotConnectedException, TimeoutException, java.io.IOException
send
in interface SenderClient
ServiceRefusedException
- If the server rejected
the send request.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.public void setTopic(java.lang.String channelName, java.lang.String topic) throws ServiceRefusedException, NotConnectedException, TimeoutException, java.io.IOException
ServiceRefusedException
- If the server rejected
the request.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.public void ship(java.lang.String nick, java.lang.String status, ShipWindow shipWindow) throws ServiceRefusedException, NotConnectedException, TimeoutException, java.io.IOException
The
- nick who gets or loses his shipson
- or offServiceRefusedException
- If the server rejected
the send request.NotConnectedException
- The client is not connected to
the server.java.io.IOException
- For problems in lower layers.public void whisper(java.lang.String channelName, java.lang.String receiver, java.lang.String text) throws ServiceRefusedException, NotConnectedException, TimeoutException, java.io.IOException
ServiceRefusedException
- If the server rejected
the send request.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.public void emotion(java.lang.String channelName, java.lang.String target, java.lang.String emotion) throws ServiceRefusedException, NotConnectedException, TimeoutException, java.io.IOException
ServiceRefusedException
- If the server rejected
the send request.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.public boolean isConnected()
isConnected
in interface SenderClient
public void play(java.lang.String channelName, java.lang.String audioKey) throws ServiceRefusedException, NotConnectedException, TimeoutException, java.io.IOException
play
in interface SenderClient
audiokey
- The name of the sound to play. The receiving
clients maps this name to a sound file and
plays that file. Default names include
Hello
plays a greeting,
Laugh
plays a laugh and
Bye
.ServiceRefusedException
- If the server rejected
the play request.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.public void disconnect() throws java.io.IOException
disconnect
in interface SenderClient
java.io.IOException
- If something broken.public void requestUserInfo(java.lang.String nickname) throws ServiceRefusedException, NotConnectedException, TimeoutException, java.io.IOException
nickname
- the user we want the information from
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |