use of co.paralleluniverse.actors.behaviors.ServerActor in project quasar by puniverse.
the class Server method main.
public static void main(String[] args) throws ExecutionException, InterruptedException {
System.setProperty("galaxy.nodeId", Integer.toString(nodeId));
System.setProperty("galaxy.port", Integer.toString(7050 + nodeId));
System.setProperty("galaxy.slave_port", Integer.toString(8050 + nodeId));
new Fiber(new ServerActor(new AbstractServerHandler<SumRequest, Integer, SumRequest>() {
@Override
public void init() throws SuspendExecution {
super.init();
Actor.currentActor().register("myServer");
System.out.println(this.toString() + " is ready");
}
@Override
public Integer handleCall(ActorRef<?> from, Object id, SumRequest m) {
System.out.println(this.toString() + " is handling " + m);
if (m.a == 0 && m.b == 0)
ServerActor.currentServerActor().shutdown();
return m.a + m.b;
}
})).start().join();
System.exit(0);
}
Aggregations