net.sf.freecol.metaserver
Class NetworkHandler

java.lang.Object
  extended by net.sf.freecol.metaserver.NetworkHandler
All Implemented Interfaces:
MessageHandler

public final class NetworkHandler
extends java.lang.Object
implements MessageHandler

Handles all network messages beeing sent to the metaserver.


Field Summary
private static java.util.logging.Logger logger
           
private  MetaRegister metaRegister
           
private  MetaServer metaServer
           
 
Constructor Summary
NetworkHandler(MetaServer metaServer, MetaRegister metaRegister)
          The constructor to use.
 
Method Summary
private  org.w3c.dom.Element disconnect(Connection connection, org.w3c.dom.Element element)
          Handles a "disconnect"-request.
private  org.w3c.dom.Element getServerList(Connection connection, org.w3c.dom.Element element)
          Handles a "getServerList"-request.
 org.w3c.dom.Element handle(Connection connection, org.w3c.dom.Element element)
          Handles a network message.
private  org.w3c.dom.Element register(Connection connection, org.w3c.dom.Element element)
          Handles a "register"-request.
private  org.w3c.dom.Element remove(Connection connection, org.w3c.dom.Element element)
          Handles a "remove"-request.
private  org.w3c.dom.Element update(Connection connection, org.w3c.dom.Element element)
          Handles an "update"-request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static java.util.logging.Logger logger

metaServer

private MetaServer metaServer

metaRegister

private MetaRegister metaRegister
Constructor Detail

NetworkHandler

public NetworkHandler(MetaServer metaServer,
                      MetaRegister metaRegister)
The constructor to use.

Parameters:
metaServer - The MetaServer this NetworkHandler has been created for.
metaRegister - An object containing a list of all the servers.
Method Detail

handle

public org.w3c.dom.Element handle(Connection connection,
                                  org.w3c.dom.Element element)
Handles a network message.

Specified by:
handle in interface MessageHandler
Parameters:
connection - The Connection the message came from.
element - The message to be processed.
Returns:
The reply (if any) or null.

getServerList

private org.w3c.dom.Element getServerList(Connection connection,
                                          org.w3c.dom.Element element)
Handles a "getServerList"-request.

Parameters:
connection - The Connection the message was received on.
element - The element containing the request.
Returns:
The reply: An Element with a list of the servers in the MetaRegister.

register

private org.w3c.dom.Element register(Connection connection,
                                     org.w3c.dom.Element element)
Handles a "register"-request.

Parameters:
connection - The connection the message was received on.
element - The element containing the request.
Returns:
The reply: null.

update

private org.w3c.dom.Element update(Connection connection,
                                   org.w3c.dom.Element element)
Handles an "update"-request.

Parameters:
connection - The connection the message came from.
element - The element containing the request.
Returns:
The reply: null.

remove

private org.w3c.dom.Element remove(Connection connection,
                                   org.w3c.dom.Element element)
Handles a "remove"-request.

Parameters:
connection - The connection the message came from.
element - The element containing the request.
Returns:
The reply: null.

disconnect

private org.w3c.dom.Element disconnect(Connection connection,
                                       org.w3c.dom.Element element)
Handles a "disconnect"-request.

Parameters:
connection - The connection the message came from.
element - The element containing the request.
Returns:
The reply: null.