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
-
ClientApplet()
-
-
available()
- Gets the number of available Messages for reading.
-
connect()
- Connects to the remote RoundRobinServerThread and creates
all needed structures for connecting.
-
disconnect()
- Disconnects from the RoundRobinServerThread and stops everything.
-
getAppletInfo()
- Gets some info on the applet.
-
getClient()
- Gets the internal client object used.
-
getGroup()
- Gets the clients group number from the server structures.
-
getNumber()
- Gets the clients number in the server structures.
-
getParameterInfo()
- Gets the applet supported parameters.
-
parse()
- Parses the html tag parameters.
-
recv()
- Reads a incomming Message.
-
send(Message)
- Sends a Message.
-
sendOK()
- Gives a recommandation if it's ok to send, in order to maintain good feedback.
-
setAAA(ClientConnectAAA)
- Sets the connect AAA method to the server.
-
setGroup(int)
- Tries to set the client's group in the server structures.
-
setMessageFilter(boolean)
- Sets the filter control Messages on/off.
-
test()
- Tests the status of the connection & others.
ClientApplet
public ClientApplet()
getAppletInfo
public String getAppletInfo()
- Gets some info on the applet.
- Overrides:
- getAppletInfo in class Applet
getParameterInfo
public String[][] getParameterInfo()
- Gets the applet supported parameters.
- Overrides:
- getParameterInfo in class Applet
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.
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.
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
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.
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
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
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
getGroup
public int getGroup()
- Gets the clients group number from the server structures.
- Returns:
- Group number
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.
getNumber
public int getNumber()
- Gets the clients number in the server structures.
- Returns:
- The clients number
getClient
public Client getClient()
- Gets the internal client object used.
- Returns:
- The internal client object
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
available
protected int available()
- Gets the number of available Messages for reading.
- Returns:
- The number of Messages available for reading
disconnect
protected void disconnect()
- Disconnects from the RoundRobinServerThread and stops everything.
Should be used in the stop() method of the child class