swpchat.protocol
Interface ReceiverClient

All Known Implementing Classes:
ReceiverServerConnection

public interface ReceiverClient

Interface of the receiver client. Connecting and disconnecting is initiated by the client, so there are methods for this. Receiving itself is initiated by the server, so it does not show up here. See also the counterpart ReceiverClient.


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
 

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. This results in a new thread listening on the server connection for ``receive::.''-Messages. Once one arrives, it is displayed in the TextArea passed in this invocation.
Parameters:
servername - The name of a spChatServer host, in a notation accepted by Socket.Socket(String,int).
nickName - The nickname to use in connecting.
outputArea - Something that can bring incoming messages to the user of the client. //X<
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. //X>

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! //X<
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. //X>

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

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