swpchat.protocol
Interface SenderClient

All Known Implementing Classes:
SenderServerConnection

public interface SenderClient

This interface defines the API to the Chat protocol on the client side. Classes implementing this interface may map them to Input/Output streams, remote procedure calls or the likes.

If the Server response is unparseable or otherwise garbled, a ProtocolException should be thrown.


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
 void play(java.lang.String channelName, java.lang.String audiokey)
          Make other clients play a sound file.
 void send(java.lang.String channelName, java.lang.String text)
          Send media to the server.
 

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.
Parameters:
servername - The name of a spChatServer host, in a notation accepted by Socket.Socket(String,int).
nickname - The desired nickname.
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
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
Parameters:
strChannel - the channel to left

send

public void send(java.lang.String channelName,
                 java.lang.String text)
          throws ServiceRefusedException,
                 NotConnectedException,
                 TimeoutException,
                 java.io.IOException
Send media to the server.
Throws:
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.

play

public void play(java.lang.String channelName,
                 java.lang.String audiokey)
          throws ServiceRefusedException,
                 NotConnectedException,
                 TimeoutException,
                 java.io.IOException
Make other clients play a sound file.
Parameters:
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.
Throws:
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.

disconnect

public void disconnect()
                throws ServiceRefusedException,
                       NotConnectedException,
                       TimeoutException,
                       java.io.IOException
Disconnect from the server. After this call, the client is always disconnected, even if an exception has been thrown!
Throws:
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.

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.
Returns:
true Iff the client (thinks it) is connected to a server.