|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
net.sf.freecol.metaserver.MetaServer
public final class MetaServer
The entry point and main controller object for the meta server.
When a new client connects to the meta server a new Connection is
made, with NetworkHandler as the control object.
net.sf.freecol.common.networking| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
private java.util.HashMap<java.net.Socket,Connection> |
connections
A hash of Connection objects, keyed by the Socket they relate to. |
private static java.util.logging.Logger |
logger
|
private NetworkHandler |
networkHandler
|
private int |
port
The TCP port that is beeing used for the public socket. |
private static int |
REMOVE_DEAD_SERVERS_INTERVAL
|
static int |
REMOVE_OLDER_THAN
|
private boolean |
running
Whether to keep running the main loop that is awaiting new client connections. |
private java.net.ServerSocket |
serverSocket
The public "well-known" socket to which clients may connect. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
MetaServer(int port)
Creates a new network server. |
|
| Method Summary | |
|---|---|
Connection |
getConnection(java.net.Socket socket)
Gets a Connection identified by a Socket. |
java.util.Iterator<Connection> |
getConnectionIterator()
Gets an iterator of every connection to this server. |
NetworkHandler |
getNetworkHandler()
Gets the control object that handles the network requests. |
int |
getPort()
Gets the TCP port that is beeing used for the public socket. |
static void |
main(java.lang.String[] args)
Creates and starts a new MetaServer. |
void |
removeConnection(Connection connection)
Removes the given connection. |
void |
run()
Starts the thread's processing. |
void |
shutdown()
Shuts down the server thread. |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, clone, 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 |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static java.util.logging.Logger logger
private static final int REMOVE_DEAD_SERVERS_INTERVAL
public static final int REMOVE_OLDER_THAN
private java.net.ServerSocket serverSocket
private java.util.HashMap<java.net.Socket,Connection> connections
private boolean running
private int port
private NetworkHandler networkHandler
| Constructor Detail |
|---|
public MetaServer(int port)
throws java.io.IOException
metaServer.start() to
start listening for new connections.
port - The TCP port to use for the public socket.
java.io.IOException - if the public socket cannot be created.| Method Detail |
|---|
public static void main(java.lang.String[] args)
MetaServer.
args - The command-line options.public void run()
Connection is made, with NetworkHandler as
the control object.
run in interface java.lang.Runnablerun in class java.lang.Threadpublic NetworkHandler getNetworkHandler()
NetworkHandler.public int getPort()
public java.util.Iterator<Connection> getConnectionIterator()
Iterator.Connectionpublic void shutdown()
public Connection getConnection(java.net.Socket socket)
Connection identified by a Socket.
socket - The Socket that identifies the
Connection
Connection.public void removeConnection(Connection connection)
connection - The connection that should be removed.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||