Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package jadex.bdi.planlib.protocols.cancelmeta;
 
Plan to handle protocol abortion according to FIPA cancel meta protocol
public class CMInitiatorPlan extends Plan
	public void body()
	{
		// Try to abort the interaction using FIPA-Cancel-Meta-Protocol.
		// Results of cancellation will be stored in interaction state (if any).
		InteractionState	statenull;
		if(hasParameter("interaction_state"))
		{
			state	= (InteractionState)getParameter("interaction_state").getValue();
		}
		// Copy message properties from initial message.
		IMessageEvent	cancelcreateMessageEvent("cm_cancel");
		// Use extra reply_with to avoid intermingling with other protocol messages.
		// Send cancel message to participants.
		long	timeout	= ((Number)getParameter("timeout").getValue()).longValue();
		sendMessage(cancel);
		long time = getTime();
		try
		{
			while(rec.size()>0)
			{
				// Wait for the replies.
				long wait_time = timeout + time - getTime();
				if(wait_time <= 0)
					break;
				IMessageEvent reply = waitForReply(cancelwait_time);
				// Store result in interaction state.
				if(state!=null)
				{
					String	response"cm_inform".equals(reply.getType()) ? .
						responsereply.getParameter(.).getValue());
				}
			}
		}
		{
			// Set result of non-responders to unknown.
			if(state!=null)
			{
				for(int i=0; i<rec.size(); i++)
				{
				}
			}		
		}
	}
New to GrepCode? Check out our FAQ X