swpchat.protocol
Interface ReceiverServer

All Known Implementing Classes:
ReceiverProtocolHandler

public interface ReceiverServer

This interface defines the API to the Chat Receiver protocol on the server side. Login and logout is initiated by the client and does not show up here. The server does initate reception on the client side, so there is a receive method. See also the counterpart ReceiverClient.


Method Summary
 void emotion(java.lang.String channel, java.lang.String from, java.lang.String target, java.lang.String emo)
           
 java.lang.String getNick()
           
 void play(java.lang.String channel, java.lang.String from, java.lang.String audiokey)
          Have the client receive the request from the sender to play the audio with the given key .
 void receive(java.lang.String channel, java.lang.String from, java.lang.String message)
          Have the client receive the data as coming from the sender.
 void receiveUserInfo(java.lang.String nickName, java.lang.String strInfo)
           
 void serve(java.net.Socket clientSocket, ClientConnection clientConnection, java.io.InputStream inputStream)
          Handle login and logout requests given by the client through the clientSocket.
 void shipReceive(java.lang.String channel, java.lang.String from, java.lang.String receiver, boolean status)
          shipReceive-method invoked by ClientConnection, responsible for transferring messages to this listening client
 void topicChanged(java.lang.String channel, java.lang.String from, java.lang.String topic)
          method to pass topicChanged
 void whispreceive(java.lang.String channel, java.lang.String from, java.lang.String message)
          Have the client receive the whispered message.
 

Method Detail

serve

public void serve(java.net.Socket clientSocket,
                  ClientConnection clientConnection,
                  java.io.InputStream inputStream)
           throws TimeoutException,
                  java.io.IOException,
                  java.security.InvalidParameterException
Handle login and logout requests given by the client through the clientSocket.
Parameters:
clientSocket - the socket the client is connected to.
channel - the communication context in which this client participates. After a successful login, it is registered as a receiver there and in the end, it is removed from it. The channel may also invoke (via the ClientConnection) this object's receive method.
clientConnection - the connection this handler is running in. It is to be inserted into the connectionCollection. //X<
Throws:
TimeoutException - thrown if an answer cannot be sent to the client in time. This is an abstraction from a InterruptedIOException.
java.io.IOException - General I/O-Exceptions that may have been raised by lower levels.
java.security.InvalidParameterException - Thrown if clientSocket is null or otherwise useless. //X>

receive

public void receive(java.lang.String channel,
                    java.lang.String from,
                    java.lang.String message)
             throws java.io.IOException,
                    java.security.InvalidParameterException
Have the client receive the data as coming from the sender. You could also say `It sends data to the client', but that would mess up the terminology. Note that there is no TimeoutException raised here, as it is quite hard to enforce it while serve is listening to logout requests.
Parameters:
from - The nickname of the sender.
message - The actual message to be sent. //X<
Throws:
java.io.IOException - General I/O-Exceptions that may have been raised by lower levels.
java.security.InvalidParameterException - Thrown if any parameter is null. //X>

whispreceive

public void whispreceive(java.lang.String channel,
                         java.lang.String from,
                         java.lang.String message)
                  throws java.io.IOException,
                         java.security.InvalidParameterException
Have the client receive the whispered message. Note that there is no TimeoutException raised here, as it is quite hard to enforce it while serve is listening to logout requests.
Parameters:
from - The nickname of the sender.
message - The actual message to be sent. //X<
Throws:
java.io.IOException - General I/O-Exceptions that may have been raised by lower levels.
java.security.InvalidParameterException - Thrown if any parameter is null. //X>

play

public void play(java.lang.String channel,
                 java.lang.String from,
                 java.lang.String audiokey)
          throws java.io.IOException,
                 java.security.InvalidParameterException
Have the client receive the request from the sender to play the audio with the given key . Note that there is no TimeoutException raised here, as it is quite hard to enforce it while serve is listening to logout requests.

There is no garanty, that the client will actually play anything or even know about a sound with the given key.

Parameters:
from - The nickname of the sender.
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. //X<
Throws:
java.io.IOException - General I/O-Exceptions that may have been raised by lower levels.
java.security.InvalidParameterException - Thrown if any parameter is null. //X>

topicChanged

public void topicChanged(java.lang.String channel,
                         java.lang.String from,
                         java.lang.String topic)
                  throws java.io.IOException,
                         java.security.InvalidParameterException
method to pass topicChanged
Parameters:
channel - the channel which distributes the topicChanged command
from - the client's nick, who changed the topic
audioKey - the topic

receiveUserInfo

public void receiveUserInfo(java.lang.String nickName,
                            java.lang.String strInfo)
                     throws java.io.IOException,
                            java.security.InvalidParameterException

getNick

public java.lang.String getNick()

emotion

public void emotion(java.lang.String channel,
                    java.lang.String from,
                    java.lang.String target,
                    java.lang.String emo)
             throws java.io.IOException

shipReceive

public void shipReceive(java.lang.String channel,
                        java.lang.String from,
                        java.lang.String receiver,
                        boolean status)
                 throws java.io.IOException,
                        java.security.InvalidParameterException
shipReceive-method invoked by ClientConnection, responsible for transferring messages to this listening client