scone.ras
Class Connection

java.lang.Object
  extended by scone.ras.Connection

public class Connection
extends java.lang.Object

A Connection Object represents a connection between two peers. This connection may establish and close more than one TCP connection over time. This class has been designed with Applets in mind. It's methods have been written to fit into an Applet's methods: init() should contain the constructor start() should contain wake() stop() should contain sleep() destroy() should contain close()


Field Summary
static java.lang.String CLOSE_DEDICATED
           
static java.lang.String CON_DEDICATED
           
static java.lang.String CON_SINGLETON
           
static java.lang.String OPEN_DEDICATED
           
static java.lang.String SLEEP
           
 
Constructor Summary
Connection(java.net.Socket socket, boolean dedicated)
          creates a connection that can be used by a server.
Connection(java.lang.String server, int port, java.lang.String className)
          creates a Connection that can be used by a client.
Connection(java.lang.String server, int port, java.lang.String className, boolean dedicated)
          creates a Connection that can be used by a client.
 
Method Summary
 void close()
           
 boolean isClosed()
           
 java.lang.String read()
           
 void sleep()
           
 void wake()
           
 void wake(java.net.Socket socket)
           
 void write(java.lang.String line)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CON_DEDICATED

public static java.lang.String CON_DEDICATED

CON_SINGLETON

public static java.lang.String CON_SINGLETON

OPEN_DEDICATED

public static java.lang.String OPEN_DEDICATED

CLOSE_DEDICATED

public static java.lang.String CLOSE_DEDICATED

SLEEP

public static java.lang.String SLEEP
Constructor Detail

Connection

public Connection(java.net.Socket socket,
                  boolean dedicated)
           throws java.io.IOException
creates a connection that can be used by a server. When the connection is sleeping, a new socket can be passed to the connection using the wake(socket) nmethod.

Parameters:
socket - a TCP Socket
Throws:
java.io.IOException

Connection

public Connection(java.lang.String server,
                  int port,
                  java.lang.String className)
           throws java.io.IOException
creates a Connection that can be used by a client. This Connection will connect to a singleton ConnectionHandler on the server. The underlying TCP-Connection can be stopped and resumed using the sleep()( and wake() methods.

Parameters:
server - the name of the server
port - the server's port
className - the name of the ConnectionHandler on the server
Throws:
java.io.IOException

Connection

public Connection(java.lang.String server,
                  int port,
                  java.lang.String className,
                  boolean dedicated)
           throws java.io.IOException
creates a Connection that can be used by a client. This Connection will connect to a singleton or dedicated ConnectionHandler on the server. The underlying TCP-Connection can be stopped and resumed using the sleep()( and wake() methods.

Parameters:
server - the name of the server
port - the server's port
className - the name of the ConnectionHandler on the server
dedicated - whether the handler is a dedicated object
Throws:
java.io.IOException
Method Detail

isClosed

public boolean isClosed()

wake

public void wake(java.net.Socket socket)
          throws java.io.IOException
Throws:
java.io.IOException

wake

public void wake()
          throws java.io.IOException
Throws:
java.io.IOException

sleep

public void sleep()
           throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

read

public java.lang.String read()
                      throws java.io.IOException
Throws:
java.io.IOException

write

public void write(java.lang.String line)
           throws java.io.IOException
Throws:
java.io.IOException