Package jade.lang.acl

Examples of jade.lang.acl.ACLMessage


    ctx = new CartagoBasicContext(a.getName(), workspaceName, workspaceHost);
  }

  @Override
  public void action() {
    ACLMessage request = myAgent.receive();
    if (request != null) {
      logger.debug("Request received. Parsing...");
      if (request.getPerformative() != ACLMessage.REQUEST) {
        logger.debug("Message with performative different from REQUEST.");
        ACLMessage notUnderstood = request.createReply();
        notUnderstood.setPerformative(ACLMessage.NOT_UNDERSTOOD);
        notUnderstood.setContent("Unable to process your request. Reason: Unprocessable performative");
        myAgent.send(notUnderstood);
        logger.debug("Not understood message (performative) sent to agent "+request.getSender().getLocalName());
      }
      else {
        logger.debug("Message with right performative.");
        try {
          String[] parsed = parseRequest(request.getContent());
         
         
        } catch (WrongProtocolRoleRequestEnactmentException e) {
          // Bad request received
          ACLMessage notUnderstood = request.createReply();
          notUnderstood.setPerformative(ACLMessage.NOT_UNDERSTOOD);
          notUnderstood.setContent("Unable to process your request. Reason: Unprocessable request content: "+request.getContent());
          myAgent.send(notUnderstood);
          logger.debug("Not understood message (content) sent to agent "+request.getSender().getLocalName());
        }
      }
    } else {
View Full Code Here


     * Tells the specified node that is should lock into busy mode.
     *
     * @param localName The name of the node to set to busy
     */
    public void setNodeBusy(String localName) {
        ACLMessage message = new ACLMessage(ACLMessage.REFUSE);
        message.addReceiver(new AID(localName, false));
        message.setContent("busy");
        send(message);
    }
View Full Code Here

        DFAgentDescription template = buildSearchTemplateForServiceAndType(
                NODE_AGENT_SERVICE_PREFIX + resource,
                NODE_AGENT_TYPE);
        try {
            DFAgentDescription[] result = DFService.search(this, template);
            ACLMessage requestMessage = new ACLMessage(ACLMessage.PROPOSE);
            requestMessage.setSender(getAID());
            requestMessage.setContent(value1 + ";" + value2);
            if (result.length == 0) {
                createNode(resource, requestMessage);
            } else {
                checkNodes(result, requestMessage, resource);
            }
View Full Code Here

     * @param requestMessage The message that should be sent if an agent
     * replies.
     * @param resource The destination resource
     */
    private void checkNodes(DFAgentDescription[] nodes, ACLMessage requestMessage, String resource) {
        ACLMessage checkMessage = new ACLMessage(ACLMessage.QUERY_IF);
        for (DFAgentDescription node : nodes) {
            checkMessage.addReceiver(node.getName());
        }

        send(checkMessage);
        addBehaviour(new NodeContactBehaviour(this, requestMessage, resource));
    }
View Full Code Here

        }

        @Override
        public void action() {
            MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.CONFIRM);
            ACLMessage message = myAgent.receive(mt);
            if (message != null) {
                requestMessage.addReceiver(message.getSender());
                myAgent.send(requestMessage);
                myAgent.addBehaviour(new ClientBehaviour());
                myAgent.removeBehaviour(this);
            } else {
                noMessageCounter++;
View Full Code Here

    class ClientBehaviour extends CyclicBehaviour {

        @Override
        public void action() {
            MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.INFORM);
            ACLMessage message = myAgent.receive(mt);
            if (message != null) {
                clientNodeGui.clearValues();
                clientNodeGui.setResultText(message.getContent());
                myAgent.removeBehaviour(this);
            } else {
                block(BLOCK_INTERVAL);
            }
        }
View Full Code Here

            super(a);
        }

        @Override
        public void action() {
            ACLMessage message = myAgent.receive();
            if (message != null) {
                Logger.getLogger(NodeAgent.class.getName()).log(Level.INFO,
                        "{0} recieved message with performative {1}.",
                        new Object[]{myAgent.getLocalName(), ACLMessage.getPerformative(message.getPerformative())});
                switch (message.getPerformative()) {
                    case ACLMessage.CANCEL:
                        Logger.getLogger(ResourceAgent.class.getName()).log(Level.INFO, "{0} shutting down.", myAgent.getLocalName());
                        myAgent.doDelete();
                        break;
                    case ACLMessage.REQUEST:
View Full Code Here

         * Sends a response to the NodeAgent
         *
         * @param message
         */
        private void sendResponse(ACLMessage message, int result) {
            ACLMessage response = message.createReply();
            response.setPerformative(ACLMessage.INFORM);
            response.setContent(Integer.toString(result));
            myAgent.send(response);
            Logger.getLogger(ResourceAgent.class.getName()).log(Level.INFO,
                    "{0} not busy anymore.",
                    myAgent.getLocalName());
        }
View Full Code Here

            sendRequest(initialMessage);
        }

        @Override
        public void action() {
            ACLMessage message = myAgent.receive();
            if (message != null) {
                resetTimeout();
                Logger.getLogger(NodeAgent.class.getName()).log(Level.INFO,
                        "{0} recieved message with performative {1}.",
                        new Object[]{myAgent.getLocalName(), ACLMessage.getPerformative(message.getPerformative())});
                switch (message.getPerformative()) {
                    case ACLMessage.CANCEL:
                        Logger.getLogger(NodeAgent.class.getName()).log(Level.INFO,
                                "{0} shutting down.",
                                myAgent.getLocalName());
                        myAgent.doDelete();
View Full Code Here

            Logger.getLogger(NodeAgent.class.getName()).log(Level.INFO,
                    "{0} is now busy.",
                    myAgent.getLocalName());
            currentMessage = message;

            ACLMessage requestMessage = new ACLMessage(ACLMessage.REQUEST);
            requestMessage.addReceiver(new AID(destinationLocalName, false));
            requestMessage.setContent(message.getContent());
            myAgent.send(requestMessage);
        }
View Full Code Here

TOP

Related Classes of jade.lang.acl.ACLMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.