|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
org.jscience.computing.game.GameServer
public class GameServer
A GameServer hosts a GamePlay object that clients can play remotely by connecting to it and following this server's protocol. JPlayerClient is known to work with this server. Every GamePlay role is represented by a different NetConnection running in a different thread. The GameServer hosts a single game and then closes all connections once the game is over (i.e. when there are no more legal moves available); if you want to play another game, you need a new GameServer. The GameServer listens to new connections only if there are still game roles left that are not taken by a connection. The GameServer feature reconnects; i.e. if a client disconnects, the server is restarted to allow a new client to take that role - until all game roles are connected again.
GamePlay,
JPlayerClient| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
static java.lang.String |
SIGNATURE
this signature must be used when creating connections to this server |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
GameServer(int serverPort,
GamePlay game,
int timeout,
Logger logger)
Creates a new GameServer object. |
|
| Method Summary | |
|---|---|
void |
connectionLost(NetConnection con)
DOCUMENT ME! |
java.lang.Thread |
createHandlerThread(NetConnection con)
DOCUMENT ME! |
java.lang.Object |
getConnectionSignature()
DOCUMENT ME! |
void |
handleMessage(java.lang.Object message,
NetConnection con)
DOCUMENT ME! |
static void |
main(java.lang.String[] args)
starts a GameServer after some GUI selections |
void |
run()
DOCUMENT ME! |
void |
shutdown()
DOCUMENT ME! |
static void |
startServerWithGUI(Logger logger)
a conveninent way to start a GameServer with a little GUI; |
| 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 |
|---|
public static final java.lang.String SIGNATURE
| Constructor Detail |
|---|
public GameServer(int serverPort,
GamePlay game,
int timeout,
Logger logger)
throws java.io.IOException
serverPort - DOCUMENT ME!game - DOCUMENT ME!timeout - DOCUMENT ME!logger - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!| Method Detail |
|---|
public static void main(java.lang.String[] args)
args - DOCUMENT ME!
public static void startServerWithGUI(Logger logger)
throws java.io.IOException
logger - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!public java.lang.Thread createHandlerThread(NetConnection con)
createHandlerThread in interface ConnectionDispatchercon - DOCUMENT ME!
MessageDelegatorpublic void connectionLost(NetConnection con)
connectionLost in interface NetConnectionHandlercon - DOCUMENT ME!public java.lang.Object getConnectionSignature()
getConnectionSignature in interface ConnectionDispatcher
public void handleMessage(java.lang.Object message,
NetConnection con)
handleMessage in interface NetConnectionHandlermessage - DOCUMENT ME!con - DOCUMENT ME!public void shutdown()
public void run()
run in interface java.lang.Runnablerun in class java.lang.Thread
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||