package omq.z.sample.calculator;

import omq.client.annotation.AsyncMethod;
import omq.server.remote.request.RemoteObject;

public class CalculatorImpl extends RemoteObject implements Calculator {
	private int x = 0;

	public CalculatorImpl() throws Exception {
		super();
	}

	private static final long serialVersionUID = 1L;

	public int add(int x, int y) {
		return x + y;
	}

	public void printHelloWorld(String message) {
		try {
			this.notify("He rebut el teu missatge");
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("Hellooo world, this is an async method :D " + message);
	}

	public int inc() {System.out.println("DOS I DOS SON 4");
		return ++x;
	}

	@Override
	@AsyncMethod(generateEvent = "SUBS")
	public int subs(int x, int y) {
		System.out.println("Executant subs: " + "x=" + x + ",y=" + y);
		return x - y;
	}

}
