📄 twophinitiator.java
字号:
protected void handleAllResponses(Vector responses) {
TwoPhInitiator.this.handleAllPh2Responses(responses);
}
};
registerLastState(b, PH2_STATE);
/* DUMMY_FINAL */
b = new OneShotBehaviour(myAgent) {
public void action() {
}
};
b.setDataStore(getDataStore());
registerLastState(b, DUMMY_FINAL);
}
/**
* This method must return the vector of ACLMessage objects to be sent.
* It is called in the first state of this protocol. This default
* implementation just returns the ACLMessage object (a CFP) passed in
* the constructor. Programmers might prefer to override this method in order
* to return a vector of CFP objects for 1:N conversations.
* @param cfp the ACLMessage object passed in the constructor
* @return a vector of ACLMessage objects. The values of the slot <code>reply-with</code>
* and <code>conversation-id</code> are ignored and regenerated automatically by this
* class. Instead user can specify <code>reply-by</code> slot representing phase0
* timeout.
*/
protected Vector prepareCfps(ACLMessage cfp) {
Vector v = new Vector(1);
v.addElement(cfp);
return v;
}
/**
* This method is called every time a <code>propose</code> message is received,
* which is not out-of-sequence according to the protocol rules. This default
* implementation does nothing; programmers might wish to override the method
* in case they need to react to this event.
* @param propose the received propose message
*/
protected void handlePropose(ACLMessage propose) {
}
/**
* This method is called every time a <code>failure</code> message is received,
* which is not out-of-sequence according to the protocol rules. This default
* implementation does nothing; programmers might wish to override the method
* in case they need to react to this event.
* @param failure the received propose message
*/
protected void handleFailure(ACLMessage failure) {
}
/**
* This method is called when all the responses of phase 0 have been collected or when
* the timeout is expired. The used timeout is the minimum value of the slot
* <code>reply-By</code> of all the CFP messages sent.By response message we
* intend here all the <code>propose, failure, not-understood</code> received messages, which
* are not out-of-sequence according to the protocol rules.
* This default implementation does nothing; programmers might
* wish to override this method to modify the Vector of initiation messages
* (<code>nextPhMsgs</code>) for next phase. More in details this Vector
* already includes messages with the performative set according to the
* default protocol rules i.e. QUERY_IF (if all responders replied with
* PROPOSE) or REJECT_PROPOSAL (if at least one responder failed or didn't reply).
* In particular, by setting the <code>reply-by</code> slot, users can
* specify a timeout for next phase.
* @param responses The Vector of all messages received as response in phase 0
* @param proposes The Vector of PROPOSE messages received as response in phase 0
* @param pendings The Vector of CFP messages for which a response has not
* been received yet.
* @param nextPhMsgs The Vector of initiation messages for next phase already
* filled with <code>QUERY_IF</code> messages (if all responders replied with
* <code>PROPOSE</code>) or <code>REJECT_PROPOSAL</code> (if at least one
* responder failed or didn't reply).
*/
protected void handleAllPh0Responses(Vector responses, Vector proposes,
Vector pendings, Vector nextPhMsgs) {
}
/**
* This method is called every time a <code>confirm</code> message is received,
* which is not out-of-sequence according to the protocol rules. This default
* implementation does nothing; programmers might wish to override the method
* in case they need to react to this event.
* @param confirm the received propose message
*/
protected void handleConfirm(ACLMessage confirm) {
}
/**
* This method is called every time a <code>disconfirm</code> message is received,
* which is not out-of-sequence according to the protocol rules. This default
* implementation does nothing; programmers might wish to override the method
* in case they need to react to this event.
* @param disconfirm the received propose message
*/
protected void handleDisconfirm(ACLMessage disconfirm) {
}
/**
* This method is called every time an <code>inform</code> message in phase 1
* is received, which is not out-of-sequence according to the protocol rules.
* This default implementation does nothing; programmers might wish to override
* the method in case they need to react to this event.
* @param inform the received propose message
*/
protected void handlePh1Inform(ACLMessage inform) {
}
/**
* This method is called in phase 1 when all the responses have been collected or when
* the timeout is expired. The used timeout is the minimum value of the slot
* <code>reply-By</code> of all the sent messages. By response message we
* intend here all the <code>disconfirm, confirm, inform</code> received messages,
* which are not out-of-sequence according to the protocol rules. This default
* implementation does nothing; programmers might wish to override the method
* in case they need to react to this event by analysing all the messages in
* just one call.
* @param responses The Vector of all messages received as response in phase 1
* @param confirms all confirms received
* @param disconfirms all disconfirms received
* @param pendings all queryIfs still pending
* @param nextPhMsgs prepared responses for next phase: <code>accept-proposal</code>
* or <code>reject-proposal</code>
*/
protected void handleAllPh1Responses(Vector responses, Vector confirms, Vector disconfirms,
Vector informs, Vector pendings, Vector nextPhMsgs) {
}
/**
* This method is called every time an <code>inform</code> message in phase 2
* is received, which is not out-of-sequence according to the protocol rules.
* This default implementation does nothing; programmers might wish to override
* the method in case they need to react to this event.
* @param inform the received propose message
*/
protected void handlePh2Inform(ACLMessage inform) {
}
/**
* This method is called every time a <code>failure</code>, a <code>disconfirm</code>
* or an <code>inform</code> message is received in phase 2, which is not out-of-sequence
* according to the protocol rules. This default implementation does nothing;
* programmers might wish to override the method in case they need to react
* to this event.
* @param old the received propose message
*/
protected void handleOldResponse(ACLMessage old) {
}
/**
* This method is called in phase 2 when all the responses have been collected.
* By response message we intend here all the <code>inform</code> (phase 2),
* <code>failure</code> (phase 0), <code>disconfirm</code> (phase 1) and
* <code>inform</code> (phase 1) received messages, which are not out-of-sequence
* according to the protocol rules. This default implementation does nothing;
* programmers might wish to override the method in case they need to react to
* this event by analysing all the messages in just one call.
* @param responses all responses received in phase 2
*/
protected void handleAllPh2Responses(Vector responses) {
}
/**
* This method is called every time a message is received in phase n (use
* <code>getCurrentPhase</code> method to know the phase), which is
* out-of-sequence according to the protocol rules. This default implementation
* does nothing; programmers might wish to override the method in case they need
* to react to this event.
* @param msg the received message
*/
protected void handleOutOfSequence(ACLMessage msg) {
}
protected void handleNotUnderstood(ACLMessage notUnderstood) {
}
public String getCurrentPhase() {
return getCurrent().getBehaviourName();
}
public Behaviour getPhase(String name) {
return getState(name);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -