Esempio n. 1
0
  public void requestSwapAppointments() {
    String conversationId = "request-swap";

    if (patientAgent.highPriorityAppointmentOwner != null) {

      System.out.println(
          patientAgent.getName()
              + " proposing to swap slot "
              + (patientAgent.allocatedAppointment + 1)
              + " with "
              + (patientAgent.swapSlot + 1));
      ACLMessage request = new ACLMessage(ACLMessage.PROPOSE);
      request.addReceiver(patientAgent.highPriorityAppointmentOwner);
      try {
        request.setContentObject(
            new SwapInfo(patientAgent.allocatedAppointment, patientAgent.swapSlot));
      } catch (IOException e) {
        e.printStackTrace();
      }
      request.setSender(patientAgent.getAID());
      request.setConversationId(conversationId);
      request.setReplyWith(conversationId + " " + System.currentTimeMillis());
      patientAgent.send(request);
      reqTemplate =
          MessageTemplate.and(
              MessageTemplate.MatchConversationId(conversationId),
              MessageTemplate.MatchInReplyTo(request.getReplyWith()));
      state = 1;
    }
  }