Class ServletConnection

java.lang.Object
  |
  +--ServletConnection
All Implemented Interfaces:
java.lang.Runnable

public class ServletConnection
extends java.lang.Object
implements java.lang.Runnable

This class connects and maintains the connection with the servlet using the HTTP protocol over port 80 and a fake keep-alive. Note that the fake keep-alive will use some extra bandwidth, but neglectably little in comparison with the message data being sent back and forth between the applet and the servlet.


Constructor Summary
ServletConnection(ConnectionHandler connectionHandler, java.lang.String servletURL)
          This creates a ServletConnection instance with the given parameters.
 
Method Summary
 void connect()
          Used to connect to the servlet with the option of handshaking.
 void disconnect()
          Used to disconnect from the servlet.
 void run()
          In the threaded part, the fake keep-alive will constantly query the servlet for new data objects.
 void writeObject(java.lang.Object obj)
          Used to write a data object to the servlet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletConnection

public ServletConnection(ConnectionHandler connectionHandler,
                         java.lang.String servletURL)
This creates a ServletConnection instance with the given parameters. Note that a connection is not made during construction.
Parameters:
connectionHandler - The connectionHandler instance.
servletURL - The URL to connect to.
Method Detail

connect

public void connect()
             throws java.lang.Exception
Used to connect to the servlet with the option of handshaking.

disconnect

public void disconnect()
Used to disconnect from the servlet.

run

public void run()
In the threaded part, the fake keep-alive will constantly query the servlet for new data objects. Once a data object is recieved it will be sent to the ConnectionHandler.
Specified by:
run in interface java.lang.Runnable

writeObject

public void writeObject(java.lang.Object obj)
                 throws java.io.IOException
Used to write a data object to the servlet.
Parameters:
obj - The object to be sent.