Package net.sf.freecol.metaserver
Class MetaServerHandler
- java.lang.Object
-
- net.sf.freecol.metaserver.MetaServerHandler
-
- All Implemented Interfaces:
MessageHandler
public final class MetaServerHandler extends java.lang.Object implements MessageHandler
Handle network messages sent to the meta-server.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
private MetaRegister
metaRegister
The register of connected FreeColServers.private MetaServer
metaServer
The encapsulated meta-server.
-
Constructor Summary
Constructors Constructor Description MetaServerHandler(MetaServer metaServer, MetaRegister metaRegister)
The constructor to use.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
disconnect(Connection connection)
Handle a "disconnect"-request.Message
handle(Connection connection, Message message)
Handle an incoming message.Message
read(Connection connection)
Read an incoming Message.private boolean
register(RegisterServerMessage message)
Handle a "register"-request.private void
remove(RemoveServerMessage message)
Handle a "remove"-request.private Message
serverList()
Handle a "serverList"-request.private void
update(UpdateServerMessage message)
Handle an "update"-request.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
metaServer
private final MetaServer metaServer
The encapsulated meta-server.
-
metaRegister
private final MetaRegister metaRegister
The register of connected FreeColServers.
-
-
Constructor Detail
-
MetaServerHandler
public MetaServerHandler(MetaServer metaServer, MetaRegister metaRegister)
The constructor to use.- Parameters:
metaServer
- TheMetaServer
thisNetworkHandler
has been created for.metaRegister
- An object containing a list of all the servers.
-
-
Method Detail
-
handle
public Message handle(Connection connection, Message message) throws FreeColException
Handle an incoming message.- Specified by:
handle
in interfaceMessageHandler
- Parameters:
connection
- TheConnection
the message arrived on.message
- TheMessage
to handle.- Returns:
- A reply message, if any.
- Throws:
FreeColException
- if the message is malformed.
-
read
public Message read(Connection connection) throws FreeColException, javax.xml.stream.XMLStreamException
Read an incoming Message.- Specified by:
read
in interfaceMessageHandler
- Parameters:
connection
- TheConnection
to read from.- Returns:
- The
Message
found, or null if none. - Throws:
FreeColException
- if the message can not be instantiated.javax.xml.stream.XMLStreamException
- if there is a problem reading the message.
-
disconnect
private void disconnect(Connection connection)
Handle a "disconnect"-request.- Parameters:
connection
- TheConnection
the message came from.
-
register
private boolean register(RegisterServerMessage message)
Handle a "register"-request.- Parameters:
message
- TheRegisterServerMessage
to process.- Returns:
- true if the server was registered.
-
remove
private void remove(RemoveServerMessage message)
Handle a "remove"-request.- Parameters:
message
- TheRemoveServerMessage
to process.
-
serverList
private Message serverList()
Handle a "serverList"-request.- Returns:
- A
ServerListMessage
with attachedServerInfo
for each current server known to the meta-register.
-
update
private void update(UpdateServerMessage message)
Handle an "update"-request.- Parameters:
message
- TheUpdateServerMessage
to process.
-
-