|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
net.sf.freecol.server.networking.Server
public final class Server
The networking server in which new clients can connect and methods
like sendToAll
are kept.
When a new client connects to the server a new Connection
is made, with UserConnectionHandler
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 |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
Server(FreeColServer freeColServer,
int port)
Creates a new network server. |
Method Summary | |
---|---|
void |
addConnection(Connection connection)
Adds a Connection into the hashmap. |
void |
addDummyConnection(Connection connection)
Adds a (usually Dummy)Connection into the hashmap. |
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. |
int |
getPort()
Gets the TCP port that is beeing used for the public socket. |
void |
removeConnection(Connection connection)
Removes the given connection. |
void |
run()
Starts the thread's processing. |
void |
sendToAll(org.w3c.dom.Element element)
Sends a network message to all connections. |
void |
sendToAll(org.w3c.dom.Element element,
Connection exceptConnection)
Sends a network message to all connections except exceptConnection (if the argument is non-null). |
void |
setMessageHandlerToAllConnections(MessageHandler messageHandler)
Sets the specified MessageHandler to all connections. |
void |
shutdown()
Shuts down the server thread. |
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 |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Server(FreeColServer freeColServer, int port) throws java.io.IOException
server.start()
to start
listening for new connections.
freeColServer
- The owner of this Server
.port
- The TCP port to use for the public socket.
java.io.IOException
- if the public socket cannot be created.Method Detail |
---|
public void run()
Connection
is made,
with UserConnectionHandler
as the control object.
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void sendToAll(org.w3c.dom.Element element, Connection exceptConnection)
exceptConnection
(if the argument is non-null).
element
- The root element of the message to send.exceptConnection
- If non-null, the
Connection
not to send to.public void sendToAll(org.w3c.dom.Element element)
element
- The root element of the message to send.public int getPort()
public void setMessageHandlerToAllConnections(MessageHandler messageHandler)
MessageHandler
to all connections.
messageHandler
- The MessageHandler
.public java.util.Iterator<Connection> getConnectionIterator()
Iterator
.Connection
public void shutdown()
public Connection getConnection(java.net.Socket socket)
Connection
identified by a Socket
.
socket
- The Socket
that identifies the
Connection
Connection
.public void addDummyConnection(Connection connection)
connection
- The connection to add.public void addConnection(Connection connection)
connection
- The connection to add.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 |