Пример #1
0
  public SSResponder(Agent a, ACLMessage initiation, DataStore store, boolean useInitiationKey) {
    super(a);
    setDataStore(store);
    this.initiation = initiation;
    initiationKey = (useInitiationKey ? INITIATION_KEY : RECEIVED_KEY);

    registerDefaultTransition(RECEIVE_NEXT, CHECK_IN_SEQ);
    registerTransition(CHECK_IN_SEQ, HANDLE_OUT_OF_SEQUENCE, OUT_OF_SEQUENCE_EXIT_CODE);
    registerDefaultTransition(
        HANDLE_OUT_OF_SEQUENCE, RECEIVE_NEXT, new String[] {HANDLE_OUT_OF_SEQUENCE});
    registerDefaultTransition(SEND_REPLY, DUMMY_FINAL);

    Behaviour b;

    // RECEIVE_NEXT
    b = new NextMsgReceiver(myAgent, getDataStore(), RECEIVED_KEY);
    registerState(b, RECEIVE_NEXT);

    // CHECK_IN_SEQ
    b = new SeqChecker(myAgent);
    registerDSState(b, CHECK_IN_SEQ);

    // HANDLE_OUT_OF_SEQUENCE
    b = new OutOfSeqHandler(myAgent);
    registerDSState(b, HANDLE_OUT_OF_SEQUENCE);

    // SEND_REPLY
    b = new NextReplySender(myAgent, REPLY_KEY, initiationKey);
    registerDSState(b, SEND_REPLY);

    // DUMMY_FINAL
    b = new DummyFinal(myAgent);
    registerLastState(b, DUMMY_FINAL);
    b.setDataStore(getDataStore());
  }
Пример #2
0
 /**
  * Utility method to register a behaviour in a state of the protocol and set the DataStore
  * appropriately
  */
 protected void registerDSState(Behaviour b, String name) {
   b.setDataStore(getDataStore());
   registerState(b, name);
 }