示例#1
0
 public void sendMessage(Message message) {
   sentMessages.add(message);
   logger.info("Sending message " + message.getContent());
   String receiver = message.getTo();
   Agent agentTo = agents.get(receiver);
   if (agentTo != null) {
     agentTo.receive(message);
   } else {
     logger.info(
         "Could not deliver message <" + message.getContent() + " to unknown agent " + receiver);
   }
 }
示例#2
0
    @Override
    protected boolean isConditionMet() {
      boolean contains = false;

      List<Message> sent = orb.getSentMessages();
      for (Message recMsg : sent) {
        if (recMsg != null) {
          boolean toOk = recMsg.getTo().equals(message.getTo());
          boolean fromOk = recMsg.getFrom().equals(message.getFrom());
          boolean contOk = recMsg.getContent().equals(message.getContent());
          if (toOk && fromOk && contOk) {
            contains = true;
            break;
          }
        }
      }
      return contains;
    }
示例#3
0
  @Override
  protected boolean work(Message message) {
    boolean handled = true;
    MessageContent content = message.getContent();
    if (content instanceof DeleteLibraryNotify) {
      DeleteLibraryNotify n = (DeleteLibraryNotify) content;
      handleDeleteLibrary(message, n);
    } else {
      handled = false;
    }

    return handled;
  }
示例#4
0
 @Override
 protected boolean isConditionMet() {
   List<Message> toHttp = mta.getMessagesToHttp();
   for (Message msg : toHttp) {
     MessageContent content = msg.getContent();
     if (content instanceof ErrorNotify) {
       if (((ErrorNotify) content).getError().equals(error)) {
         return true;
       }
     }
   }
   return false;
 }
  @Override
  protected boolean work(Message message) {
    boolean handled = true;
    MessageContent content = message.getContent();

    if (content instanceof SynonymousTermsAsk) {
      handleSynonymousTermsAsk(message, (SynonymousTermsAsk) content);
    } else {
      handled = false;
    }

    return handled;
  }
示例#6
0
    @Override
    protected Message askUserAgentForAuthentication(Agent agent, Message loginMsg)
        throws TimeoutException {
      String login = ((LoginAsk) loginMsg.getContent()).getLogin();
      MessageContent tell = null;

      if (login.equals(TIMEOUT_LOGIN)) {
        throw new TimeoutException();
      } else if (login.equals(WRONG_LOGIN)) {
        tell = new ErrorNotify(ErrorConstants.LOGIN_WRONG_PASSWORD);
      } else {
        tell = getLoginTell(login);
      }

      Message message = loginMsg.tell(tell);

      return message;
    }