|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectboardgame.Server
public class Server
Generic boardgame server. TODO The winner determination in case of a client error won't make sense unless it's a 2-player game. TODO The facility for the board to issue moves by returning Move.BOARD as the turn has not been tested all that well. TODO handling of Move.getReceivers() is not well tested. To start a server, execute its run() method. This will listen for clients and launch handler threads for each before returning. Any further work is done by these handler threads. The GUI dispatch thread may also call certain methods. Note that the call to run() returns as soon as the ClientHandler threads are started. A note on synchronization: The methods of this class will be called by 3 types of threads: - A) The thread executing the run() method - B) The ClientHandler threads (started by the run() method) - C) The GUI Thread The entry points for these threads are synchronized on the Server object's lock, except for the run() method. This is because the thread would not release the lock while waiting for connections. For this reason it is unsafe to manipulate the Server object while the run() method may be executing, with the exception of the killServer() method. This could probably be fixed by using yet another thread to accept the connections. Calls to the GUI, if present, are done using the EventQueue.invokeLater() facility, so that they are invoked by the AWT event dispatch thread.
| Field Summary | |
|---|---|
protected static boolean |
DBGNET
|
protected static java.lang.String |
DEFAULT_BOARDCLASS
|
protected static int |
DEFAULT_PORT
|
protected static int |
DEFAULT_TIMEOUT
|
protected static boolean |
DUMPBOARD
|
protected static java.lang.String |
LOG_DIR
|
protected static java.lang.String |
LOG_PREFIX
|
protected static java.lang.String |
LOG_SUFFIX
|
protected static int |
MAX_SERVERS
|
protected static java.lang.String |
OUTCOME_FILE
|
protected static java.lang.String |
VERSION
|
| Constructor Summary | |
|---|---|
Server(Board b,
boolean createGUI)
Create a server which will create its own socket to listen on |
|
Server(Board b,
boolean createGUI,
boolean qt,
int svPort,
int to)
Create a server which will create its own socket to listen on |
|
Server(Board b,
boolean createGUI,
boolean qt,
java.net.ServerSocket ss,
int to)
Create a server which accepts two connections from the given socket. |
|
| Method Summary | |
|---|---|
java.lang.String |
getHostName()
Returns "localhost" or the hostname if the run() method has completed |
int |
getPort()
|
static void |
main(java.lang.String[] args)
|
void |
run()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.String VERSION
protected static final int DEFAULT_PORT
protected static final int DEFAULT_TIMEOUT
protected static final java.lang.String DEFAULT_BOARDCLASS
protected static final boolean DBGNET
protected static final boolean DUMPBOARD
protected static final int MAX_SERVERS
protected static final java.lang.String LOG_DIR
protected static final java.lang.String OUTCOME_FILE
protected static final java.lang.String LOG_PREFIX
protected static final java.lang.String LOG_SUFFIX
| Constructor Detail |
|---|
public Server(Board b,
boolean createGUI,
boolean qt,
java.net.ServerSocket ss,
int to)
public Server(Board b,
boolean createGUI)
public Server(Board b,
boolean createGUI,
boolean qt,
int svPort,
int to)
| Method Detail |
|---|
public static void main(java.lang.String[] args)
public java.lang.String getHostName()
public int getPort()
public void run()
run in interface java.lang.Runnable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||