/* ************************************************************************
#
#  DivConq
#
#  http://divconq.com/
#
#  Copyright:
#    Copyright 2012 eTimeline, LLC. All rights reserved.
#
#  License:
#    See the license.txt file in the project's top-level directory for details.
#
#  Authors:
#    * Andy White
#
************************************************************************ */
package divconq.bus;

import divconq.bus.Message;
 
// this is good for one call back only
abstract public class ServiceResponse implements IServiceResponse {
	private int state = 0;  // 1 = delivered, -1 = canceled
	
	@Override
	public void response(Message rmsg) {
		synchronized(this) {
			if (this.state != 0)
				return;
			
			this.state = 1;
		}
		
		this.safeResponse(rmsg);
	}
	
	public abstract void safeResponse(Message rmsg);
}
