Class ClientApplet

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----ClientApplet

public abstract class ClientApplet
extends Applet
A abstract Applet class that implements the necesary connecting and messaging functions for connecting and communicating with the RoundRobinServerThread

In order not to overload the server a simple CTS mechanism is implemented. The client should NOT SEND again, before it receives a CTS Message from the server. He is allowed to send, but the Message just gets queued up and the feedback becomes slower, The method sendOK() returns a value that tests if some CTS Message was received and no other Message was sent. You have the option to change if the control Messages reach the child class or not.

Written: Radu Sion
Version: 0.49
Source: ClientApplet.java

See Also:
Client, Message, RoundRobinServerThread, ConnectServerThread, TCPIPThread

Constructor Index

 o ClientApplet()

Method Index

 o available()
Gets the number of available Messages for reading.
 o connect()
Connects to the remote RoundRobinServerThread and creates all needed structures for connecting.
 o disconnect()
Disconnects from the RoundRobinServerThread and stops everything.
 o getAppletInfo()
Gets some info on the applet.
 o getClient()
Gets the internal client object used.
 o getGroup()
Gets the clients group number from the server structures.
 o getNumber()
Gets the clients number in the server structures.
 o getParameterInfo()
Gets the applet supported parameters.
 o parse()
Parses the html tag parameters.
 o recv()
Reads a incomming Message.
 o send(Message)
Sends a Message.
 o sendOK()
Gives a recommandation if it's ok to send, in order to maintain good feedback.
 o setAAA(ClientConnectAAA)
Sets the connect AAA method to the server.
 o setGroup(int)
Tries to set the client's group in the server structures.
 o setMessageFilter(boolean)
Sets the filter control Messages on/off.
 o test()
Tests the status of the connection & others.

Constructors

 o ClientApplet
 public ClientApplet()

Methods

 o getAppletInfo
 public String getAppletInfo()
Gets some info on the applet.

Overrides:
getAppletInfo in class Applet
 o getParameterInfo
 public String[][] getParameterInfo()
Gets the applet supported parameters.

Overrides:
getParameterInfo in class Applet
 o setAAA
 protected void setAAA(ClientConnectAAA a)
Sets the connect AAA method to the server. Should be used BEFORE the call to connect inside the init() method of the child class.

Parameters:
a - AAA method/object to use when connecting to the server.
 o parse
 protected boolean parse()
Parses the html tag parameters. Should be used in the init() method in the child class.

Returns:
Returns true if everything ok, false otherwise.
 o connect
 protected boolean connect()
Connects to the remote RoundRobinServerThread and creates all needed structures for connecting. Should be used in the start() method of the child class.

Returns:
Returns true if ok, false otherwise
 o test
 public boolean test()
Tests the status of the connection & others. The child class should shutdown if the return is false.

Returns:
Returns true if ok, false otherwise.
 o send
 public void send(Message m) throws FullException
Sends a Message. It's internally synchronized !!!

Parameters:
m - The Message to send
Throws: FullException
When the outgoing queue is full
 o sendOK
 public synchronized boolean sendOK()
Gives a recommandation if it's ok to send, in order to maintain good feedback. The issue is not to fill the queues by the server. If they are full then the feedback will be very bad because the incoming Messages (from the clients) will be handled only after the ones in the queue. If the queue is not too long then it's ok. But who knows. Use it before you send any other Message.

Returns:
If true then it's ok to send, else wait
 o setMessageFilter
 public void setMessageFilter(boolean how)
Sets the filter control Messages on/off. By default the control Messages (CTS,NOP,etc) will reach also the child class. If you change this, recv() will more often throw EmptyException.

Parameters:
filter - If true sets the filtering on, else off
 o getGroup
 public int getGroup()
Gets the clients group number from the server structures.

Returns:
Group number
 o setGroup
 public void setGroup(int newgroup)
Tries to set the client's group in the server structures. The change will not be imediately and may not happen if the requested group is invalid. No return is made and no guaranties are given (in this version) that the request will be fulfilled. Generaly speaking everything should be ok.

 o getNumber
 public int getNumber()
Gets the clients number in the server structures.

Returns:
The clients number
 o getClient
 public Client getClient()
Gets the internal client object used.

Returns:
The internal client object
 o recv
 public Message recv() throws EmptyException
Reads a incomming Message. It's internally synchronized !!! (is it really ?)

Returns:
The read Message
Throws: EmptyException
When there is nothing to read
 o available
 protected int available()
Gets the number of available Messages for reading.

Returns:
The number of Messages available for reading
 o disconnect
 protected void disconnect()
Disconnects from the RoundRobinServerThread and stops everything. Should be used in the stop() method of the child class