its.element
Class ConnectionDaemon

java.lang.Object
  extended byits.element.ConnectionDaemon
All Implemented Interfaces:
java.lang.Runnable

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

Manages a thread that accepts client requests on a server socket and spawns an instance of OutputBuffer in a new thread for each client it accepts.


Constructor Summary
ConnectionDaemon(int requestPort, AccessManager accessManager, OutputQueue dataQueue)
           
ConnectionDaemon(int requestPort, OutputQueue dataQueue)
          Creates a server socket listening to the given port and creates a new thread to execute this object's run method.
 
Method Summary
protected  boolean authorized(java.net.Socket client)
          Placeholder for function to check if client is authorized to connect.
 int getClientCount()
           
 void run()
          Main loop for ConnectionDaemon thread.
 void setAccessManager(AccessManager am)
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionDaemon

public ConnectionDaemon(int requestPort,
                        OutputQueue dataQueue)
                 throws java.io.IOException
Creates a server socket listening to the given port and creates a new thread to execute this object's run method.

Parameters:
requestPort - the port on which to listen for connection attempts
dataQueue - the object used as a source of ItsFrames to pass to connected clients

ConnectionDaemon

public ConnectionDaemon(int requestPort,
                        AccessManager accessManager,
                        OutputQueue dataQueue)
                 throws java.io.IOException
Method Detail

setAccessManager

public void setAccessManager(AccessManager am)

run

public void run()
Main loop for ConnectionDaemon thread. It accepts a new connection from ServerSocket, checks that resources are available and that the connection is authorized, and spawns a new OutputBuffer if necessary.

Specified by:
run in interface java.lang.Runnable

authorized

protected boolean authorized(java.net.Socket client)
Placeholder for function to check if client is authorized to connect. Could be overridden by a subclass. Default implementation checks with the access manager. This should be sufficient for most apps since the (counting) access manager is quite general.


stop

public void stop()

getClientCount

public int getClientCount()