swpchat.protocol
Interface ControlServer

All Known Implementing Classes:
ControlProtocolHandler

public interface ControlServer

Interface for the server's ControlConnection to client. These methods ar used and must be implemented.


Method Summary
 void disconnect()
          finally we have to remove the session from connectedClientCollection and we have to remove our nick and sessionKey from nickNameCollection
 void handleNormalRequests(java.util.Vector tokenlist)
          method handles the command that is saved in the tokenlist
 void notify(java.lang.String nick, java.lang.String state, java.lang.String channels)
          Notify ClientConnection that 'nick' assumed 'state' concerning 'channels'.
 void sendControlMessage(java.lang.String command, java.lang.String message1, java.lang.String message2)
          method interrupts receiverThread and then receives itself all incoming messages until the reply, we have been waiting (after sending request) for, occurs or comes not within 5 seconds.
 void sendRequestMessage(java.lang.String request, java.lang.String info1, java.lang.String info2, java.lang.String info3)
          method interrupts receiverThread and then receives itself all incoming messages until the reply, we have been waiting (after sending request) for, occurs or comes not within 5 seconds.
 void serve(java.net.Socket socket, ClientConnection client, java.io.InputStream inputStream)
          implementation of method serve from ProtocolHandler instantiate new ControlProtocolReceiverThread
 

Method Detail

serve

public void serve(java.net.Socket socket,
                  ClientConnection client,
                  java.io.InputStream inputStream)
           throws TimeoutException,
                  java.io.IOException,
                  java.security.InvalidParameterException
implementation of method serve from ProtocolHandler instantiate new ControlProtocolReceiverThread
Parameters:
{@link - java.net.Socket}, the socket that must be served
{@link - swpchat.server.ClientConnection}, the Thread that runs
{@link - java.io.InputStream}, the Stream that must be read from
Throws:
TimeoutException - thrown if connection to the client is lost or too slow.
java.io.IOException - thrown for any I/O error.
java.security.InvalidParameterException - possibly useful

handleNormalRequests

public void handleNormalRequests(java.util.Vector tokenlist)
                          throws java.io.IOException,
                                 java.net.ProtocolException
method handles the command that is saved in the tokenlist
Parameters:
{@link - java.util.Vector} contains the Tokens of the command
Throws:
java.net.ProtocolException - thrown if Protocol is injured.
java.io.IOException - thrown for any I/O error.

sendControlMessage

public void sendControlMessage(java.lang.String command,
                               java.lang.String message1,
                               java.lang.String message2)
method interrupts receiverThread and then receives itself all incoming messages until the reply, we have been waiting (after sending request) for, occurs or comes not within 5 seconds. Finally starts receiverThread again. Threadsave, because many Thread could send messages to the client.
Parameters:
control - is the {@java.lang.String} that identifys the command
message1 - is a {@java.lang.String} specifying part1 of message
message2 - is a {@java.lang.String} specifying part2 of message

sendRequestMessage

public void sendRequestMessage(java.lang.String request,
                               java.lang.String info1,
                               java.lang.String info2,
                               java.lang.String info3)
method interrupts receiverThread and then receives itself all incoming messages until the reply, we have been waiting (after sending request) for, occurs or comes not within 5 seconds. Finally starts receiverThread again. Threadsave, because many Thread could send messages to the client.
Parameters:
request - is the {@java.lang.String} that identifys the request
info1 - is a {@java.lang.String} specifying part1 of message
info2 - is a {@java.lang.String} specifying part2 of message
info3 - is a {@java.lang.String} specifying part3 of message

notify

public void notify(java.lang.String nick,
                   java.lang.String state,
                   java.lang.String channels)
Notify ClientConnection that 'nick' assumed 'state' concerning 'channels'. Example: 'nick' is NotificationTokens.STR_STATE_ONLINE and joined some channels, whereas channels contains a list of the channels simply divided by ';'s.
Parameters:
nick - String specifying the nickname of the concerning the message
state - String specifying the state 'nick' assumed. The valid states can be found in NotificationTokens.
channels - String specifying the channels joined or left devided by ';'s. Example: 'nick' joined 'test' and 'swp' up to now. Then channels can be "test;swp".

disconnect

public void disconnect()
finally we have to remove the session from connectedClientCollection and we have to remove our nick and sessionKey from nickNameCollection