Class MetaServerHandler

  • All Implemented Interfaces:
    MessageHandler

    public final class MetaServerHandler
    extends java.lang.Object
    implements MessageHandler
    Handle network messages sent to the meta-server.
    • 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 - The MetaServer this NetworkHandler has been created for.
        metaRegister - An object containing a list of all the servers.
    • Method Detail

      • read

        public Message read​(Connection connection)
                     throws FreeColException,
                            javax.xml.stream.XMLStreamException
        Read an incoming Message.
        Specified by:
        read in interface MessageHandler
        Parameters:
        connection - The Connection 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 - The Connection the message came from.
      • register

        private boolean register​(RegisterServerMessage message)
        Handle a "register"-request.
        Parameters:
        message - The RegisterServerMessage to process.
        Returns:
        true if the server was registered.
      • remove

        private void remove​(RemoveServerMessage message)
        Handle a "remove"-request.
        Parameters:
        message - The RemoveServerMessage to process.
      • serverList

        private Message serverList()
        Handle a "serverList"-request.
        Returns:
        A ServerListMessage with attached ServerInfo for each current server known to the meta-register.
      • update

        private void update​(UpdateServerMessage message)
        Handle an "update"-request.
        Parameters:
        message - The UpdateServerMessage to process.