package org.biomoby.client;

/**
 * This interface is used for callbacks when MobyRequest is acting as a server or client.
 * Similar to how a MouseListener will get mousePressed() callbacks for GUI 
 * components it is registered with (via component.addMouseListener()), 
 * processEvent() will be called in the implementing class when MOBYRequest 
 * receives a connection from a client [server mode], or receives a response 
 * from a server [client mode].  This of course requires that you've registered the listener using  
 * MobyRequest.addEventHandler().
 */
public interface MobyRequestEventHandler{

    /**
     * If a client, denotes that a service request has been sent (and the contents is exactly what is being sent to the service).
     * If a server, denotes that you should be ready to start receiving events (an init of sorts)
     */
    public void start(MobyRequestEvent request);

    public void processEvent(MobyRequestEvent mre);

    /**
     * If a client, denotes the end of a service request.
     * If a server, denotes that the server is shutting down/this event handler should terminate.
     */
    public void stop(MobyRequest request, int requestID);

}
