package omq.ztest.calculator;

import java.io.IOException;

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

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

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

	private static final long serialVersionUID = 1L;

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

	public void mult(int x, int y) {
		mult = x * y;
	}

	public int getMult() {
		return mult;
	}

	public void setMult(int mult) {
		this.mult = mult;
	}

	public void divideByZero() throws IOException, SerializerException {
		ZeroEvent ze = new ZeroEvent("my zero event");
		notifyEvent(ze);
	}

	@Override
	@AsyncMethod
	public void sendMessage(Message m) {
		System.out.println("Code = "+m.getCode());
		System.out.println("Message = "+m.getMessage());
	}
	
	

}
