Ver. 20060815

Server
Class ConnectionContainer

java.lang.Object
  extended by Server.ConnectionContainer
Direct Known Subclasses:
ClientContainer, ModuleContainer

public abstract class ConnectionContainer
extends java.lang.Object

Abstract encapsulation of an incoming socket connection. Maintains the state of the connection within the server. Provides the API for all incomming connections. Can be inherited to create specialized connection types. 2006/08/10 Kyle Reed


Field Summary
protected  byte[] ba
           
protected  java.nio.ByteBuffer bb
           
protected  int challengeNum
           
protected  boolean connected
           
protected  java.lang.String idName
           
protected  int idNum
           
protected  java.nio.channels.SocketChannel io
           
protected  java.nio.channels.SelectionKey myKey
           
(package private) static Server server
           
protected  java.util.Date startTime
           
private static int totalConnections
           
 
Constructor Summary
ConnectionContainer(java.nio.channels.SelectionKey key)
          Creates a generic container for an incoming connection.
 
Method Summary
 int getChallengeNum()
          Returns the object's challenge number.
 int getIdNum()
          Returns the container's UID.
 java.lang.String getName()
          Returns the object's display name.
 long getUptime()
          Returns the object's connected time in seconds.
abstract  void handleInput()
          Tells the container to read its input from io socket and process it accordingly.
abstract  void selfDestruct()
          Abstract method to get the object's data structures ready for garbage collection.
 void sendTerminator()
          Send the close tag to the output stream to let the client know that the connection is about to be closed.
 void setName(java.lang.String s)
          Sets the object's display name.
static void setServer(Server s)
           
 void writeToSelf(java.lang.String s)
          Writes a string out on the SocketChannel output stream that belongs to the SelectionKey passed to the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

totalConnections

private static int totalConnections

server

static Server server

myKey

protected java.nio.channels.SelectionKey myKey

idNum

protected int idNum

idName

protected java.lang.String idName

startTime

protected java.util.Date startTime

challengeNum

protected int challengeNum

connected

protected boolean connected

io

protected java.nio.channels.SocketChannel io

bb

protected java.nio.ByteBuffer bb

ba

protected byte[] ba
Constructor Detail

ConnectionContainer

public ConnectionContainer(java.nio.channels.SelectionKey key)
Creates a generic container for an incoming connection. This class is abstract and cannot be directly instantiated. Sets the object UID, the default parameters. 2006/08/10 Kyle Reed

Method Detail

setServer

public static void setServer(Server s)

handleInput

public abstract void handleInput()
Tells the container to read its input from io socket and process it accordingly. This was added to simplify routing in the server and allowing 200 lines of routing functions to be replaced with about 20 lines in the container. 2006/08/10 Kyle Reed


writeToSelf

public void writeToSelf(java.lang.String s)
Writes a string out on the SocketChannel output stream that belongs to the SelectionKey passed to the constructor. Basically it writes to the connection. 2006/08/10 Kyle Reed


sendTerminator

public void sendTerminator()
Send the close tag to the output stream to let the client know that the connection is about to be closed. 2006/08/10 Kyle Reed


selfDestruct

public abstract void selfDestruct()
Abstract method to get the object's data structures ready for garbage collection. 2006/08/10 Kyle Reed


getIdNum

public int getIdNum()
Returns the container's UID. 2006/08/10 Kyle Reed


getChallengeNum

public int getChallengeNum()
Returns the object's challenge number. 2006/08/10 Kyle Reed


getUptime

public long getUptime()
Returns the object's connected time in seconds. 2006/08/10 Kyle Reed


getName

public java.lang.String getName()
Returns the object's display name. 2006/08/10 Kyle Reed


setName

public void setName(java.lang.String s)
Sets the object's display name. 2006/08/10 Kyle Reed


Ver. 20060815