swpchat.protocol
Interface ControlClient

All Known Implementing Classes:
ControlConnection

public interface ControlClient

Interface for the ControlConnection of the client. These methods are used and must be implemented.


Method Summary
 void changeNick(java.lang.String sessionKey, java.lang.String newNick)
          Change the nickname.
 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 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 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.
 

Method Detail

connect

public void connect(java.lang.String servername,
                    java.lang.String nickname)
             throws ServiceRefusedException,
                    TimeoutException,
                    java.io.IOException
Connect to the server.
Parameters:
servername - The server to connect to.
nickname - The user's choosen nickname.
Throws:
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.

changeNick

public void changeNick(java.lang.String sessionKey,
                       java.lang.String newNick)
                throws ServiceRefusedException,
                       NotConnectedException,
                       TimeoutException,
                       java.io.IOException,
                       java.net.ProtocolException
Change the nickname.
Throws:
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.

createNewChannel

public void createNewChannel(java.lang.String name,
                             java.lang.String sendPasswd,
                             java.lang.String recvPasswd)
                      throws NotConnectedException,
                             java.io.IOException,
                             TimeoutException,
                             ServiceRefusedException
sends a create new channel request to the server.
Parameters:
name - The channel name.
sendPasswd - The password for restricted access for senders
recvPasswd - The password for restricted access for receivers
Throws:
NotConnectedException - if we are not connected to the server.
TimeoutException - if the server does not respond within the timeout
ServiceRefusedException - if the server refuses creating a new channel
java.io.IOException - on IO propblems in lower layers

renameChannel

public void renameChannel(java.lang.String oldname,
                          java.lang.String newname)
                   throws NotConnectedException,
                          java.io.IOException,
                          TimeoutException,
                          java.net.ProtocolException,
                          ServiceRefusedException
renames an existing channel, but not used yet.
Parameters:
name - The channel name.
Throws:
NotConnectedException - if we are not connected to the server.
TimeoutException - if the server does not respond within the timeout
ServiceRefusedException - if the server refuses creating a new channel
java.io.IOException - on IO propblems in lower layers
java.net.ProtocolException - if we receive an unexpected answer.

removeChannel

public void removeChannel(java.lang.String name)
                   throws NotConnectedException,
                          java.io.IOException,
                          TimeoutException,
                          java.net.ProtocolException,
                          ServiceRefusedException
removes an existing channel, but not used yet.
Parameters:
name - The channel name.
Throws:
NotConnectedException - if we are not connected to the server.
TimeoutException - if the server does not respond within the timeout
ServiceRefusedException - if the server refuses creating a new channel
java.io.IOException - on IO propblems in lower layers
java.net.ProtocolException - if we receive an unexpected answer.

handleNormalReceiving

public void handleNormalReceiving(java.util.Vector tokenlist)
                           throws java.io.IOException,
                                  java.net.ProtocolException
Handles all received messages a receiver control connection would handle, such as newChannel or removeChannel.
Parameters:
tokenlist - The tokenlist got from InputStream.
Throws:
java.io.IOException - on problems of lower IO - level
java.net.ProtocolException - on receiving an unexpected answer

disconnect

public void disconnect()
                throws NotConnectedException,
                       java.io.IOException,
                       TimeoutException,
                       java.net.ProtocolException
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.
TimeoutException - If the server does not respond within the timeout.
java.net.ProtocolException - If receiving an unexpected answer.

isConnected

public boolean isConnected()
Checks if the control unit is connected to the server.

getSessionKey

public java.lang.String getSessionKey()
Gets the actual session key and returns it.