
package forager.server;

import java.io.IOException;

import java.util.logging.Level;
import java.util.logging.Logger;

import forager.events.ForagerEventMap;
import forager.events.JoinEvent;

import galileo.event.EventHandler;
import galileo.net.GalileoMessage;
import galileo.net.MessageListener;
import galileo.net.NetworkDestination;
import galileo.net.ServerMessageRouter;

public class Overlord implements MessageListener {

    private static final Logger logger = Logger.getLogger("forager");

    private int port;
    private ServerMessageRouter messageRouter;

    private ForagerEventMap eventMap = new ForagerEventMap();
    private EventMapper eventMapper = new EventMapper(this, eventMap);

    public Overlord(int port) {
        this.port = port;
        eventMapper.linkEventHandlers();
    }

    public void start()
    throws IOException, Exception {
        messageRouter = new ServerMessageRouter(this.port);
        messageRouter.addListener(this);
        messageRouter.addListener(eventMapper);
        messageRouter.listen();

        while (true) {
            eventMapper.processNextEvent();
        }
    }

    @Override
    public void onConnect(NetworkDestination endpoint) {

    }

    @Override
    public void onDisconnect(NetworkDestination endpoint) {

    }

    @Override
    public void onMessage(GalileoMessage message) { }

    @EventHandler
    public void processJoinEvent(JoinEvent join) {
        logger.log(Level.INFO, "Received join request: {0}", "xxx");
    }

    public static void main(String[] args)
    throws Exception {
        if (args.length < 1) {
            System.out.println("Usage: forager.server.Overlord <port>");
            System.exit(1);
        }

        int port = Integer.parseInt(args[0]);

        Overlord overlord = new Overlord(port);
        overlord.start();
    }
}

@@ -218,24 +218,59 @@
 entHandler;%0A
+import galileo.event.EventReactor;%0A
 import galil
@@ -292,16 +292,16 @@
 essage;%0A
-
 import g
@@ -684,25 +684,27 @@
 vent
-Mappe
+Reacto
 r event
-Mappe
+Reacto
 r = 
@@ -712,21 +712,22 @@
 ew Event
-Mappe
+Reacto
 r(this, 
@@ -809,21 +809,22 @@
    event
-Mappe
+Reacto
 r.linkEv
@@ -1045,21 +1045,22 @@
 er(event
-Mappe
+Reacto
 r);%0A    
@@ -1132,13 +1132,14 @@
 vent
-Mappe
+Reacto
 r.pr

Change over to Galileo EventReactor implementation