fang
Class HttpServer

java.lang.Object
  extended by java.lang.Thread
      extended by fang.HttpServer
All Implemented Interfaces:
Runnable

public class HttpServer
extends Thread

This establishes incoming connections and directs them to the appropriate GameConnection. The Server can be run continually on a dedicated computer to serve all multiclient games.

Author:
Jam Jenkins

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static int PORT
          port on which to run the server
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
HttpServer()
          the constructor to use in applications
HttpServer(Object dummy)
          the constructor to use when using pipes
 
Method Summary
 void connect()
          connects to a client and forwards the connections to the proper GameConnection
 void disconnect()
          stops the loop from accepting new connections
 ObjectInputStream getPipedInput()
          makes a piped input stream to use in applets
 ObjectOutputStream getPipedOutput()
          makes a piped output stream to use in applets
static void main(String[] argv)
          starts the server accepting new connections
 void run()
          starts the pipes for applets, or the server for applications
 void startPipes()
          starts pipe communications
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PORT

public static int PORT
port on which to run the server

Constructor Detail

HttpServer

public HttpServer(Object dummy)
the constructor to use when using pipes


HttpServer

public HttpServer()
           throws IOException
the constructor to use in applications

Throws:
IOException
Method Detail

getPipedInput

public ObjectInputStream getPipedInput()
makes a piped input stream to use in applets

Returns:
the piped input stream connected to the server

getPipedOutput

public ObjectOutputStream getPipedOutput()
makes a piped output stream to use in applets

Returns:
the piped output stream connected to the server

startPipes

public void startPipes()
starts pipe communications


connect

public void connect()
connects to a client and forwards the connections to the proper GameConnection

Throws:
Exception - if an error occurs while establishing the initial connections

disconnect

public void disconnect()
stops the loop from accepting new connections


run

public void run()
starts the pipes for applets, or the server for applications

Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Runnable.run()

main

public static void main(String[] argv)
                 throws IOException
starts the server accepting new connections

Parameters:
argv - not used
Throws:
IOException