use of org.apollo.game.io.MessageHandlerChainSetParser in project apollo by apollo-rsps.
the class GameService method init.
/**
* Initializes the game service.
*
* @throws IOException If there is an error accessing the file.
* @throws SAXException If there is an error parsing the file.
* @throws ReflectiveOperationException If a MessageHandler could not be created.
*/
private void init() throws IOException, SAXException, ReflectiveOperationException {
try (InputStream input = new FileInputStream("data/messages.xml")) {
MessageHandlerChainSetParser chainSetParser = new MessageHandlerChainSetParser(input);
handlers = chainSetParser.parse(world);
}
try (InputStream input = new FileInputStream("data/synchronizer.xml")) {
XmlParser parser = new XmlParser();
XmlNode root = parser.parse(input);
if (!root.getName().equals("synchronizer")) {
throw new IOException("Invalid root node name.");
}
XmlNode active = root.getChild("active");
if (active == null || !active.hasValue()) {
throw new IOException("No active node/value.");
}
Class<?> clazz = Class.forName(active.getValue());
synchronizer = (ClientSynchronizer) clazz.newInstance();
}
}
Aggregations