|
|||||||||
| 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.SocketPlayerServer
public class SocketPlayerServer
SocketPlayerServer provides the capability of taking network requests
from a SocketPlayer. SocketPlayerServer runs in a thread which when
instanciated binds itself to a Socket. When the start() method is invoked
(or run() is explicitly called), the SocketPlayer Server will listen for
incoming requests as long as the boolean value in the given monitor (see
constructor) is true. If no monitor is given, no monitoring or external
stopping of the SocketPlayerServer is possible; after starting, the Server
will be in an infinitive loop. Use of the monitor:
SocketPlayerServer needs a monitor with (monitor.getSize() >= 3);
monitor.timer[0] has the non-idle time of this server,
monitor.getNumber(0) has the number of requests made to the server
and monitor.getObject(0) has a String with the current status message.
monitor.object[1] keeps a String of the last connection made.
monitor.object[2] holds the last object sent through
SocketPlayer.sendMessage(Object message).
In addition, for each connection made, SocketPlayerServer updates a status
message in the monitor 3 times (when a connection is made, when the tasks
finishes and when the SocketPlayerServer is idle again). This status
message will be written as a String into monitor.setObject(0) each time. To
give a monitoring process the ability to timely react on each event, the
monitor needs to have been initialized with a custom task, since for each
status message update, SocketPlayerServer calls monitor.runTask().
Limitation: the protocol is still fairly primitive; any exceptions that may
be thrown by the embedded actual Player object are not propagated but cause
the connection to reset.
SocketPlayer,
Monitor| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
static int |
SO_TIMEOUT
DOCUMENT ME! |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
SocketPlayerServer(int port,
Player player,
Monitor monitor,
Logger logger)
The constructor binds itself to the given port and keeps a reference to the actual Player object. |
|
| Method Summary | |
|---|---|
protected void |
finalize()
DOCUMENT ME! |
Player |
getPlayer()
DOCUMENT ME! |
void |
run()
run() listens at the port specified in the constructor for a connecton from a SocketPlayer and routes all requests through to the embedded Player object as long as the Monitor object given to the constructor is disabled. |
java.lang.String |
toString()
DOCUMENT ME! |
| 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, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static int SO_TIMEOUT
| Constructor Detail |
|---|
public SocketPlayerServer(int port,
Player player,
Monitor monitor,
Logger logger)
port - DOCUMENT ME!player - DOCUMENT ME!monitor - DOCUMENT ME!logger - DOCUMENT ME!| Method Detail |
|---|
public void run()
run in interface java.lang.Runnablerun in class java.lang.ThreadSocketPlayer,
Monitor
protected void finalize()
throws java.io.IOException
finalize in class java.lang.Objectjava.io.IOException - DOCUMENT ME!public java.lang.String toString()
toString in class java.lang.Threadpublic Player getPlayer()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||