Search code examples
javapugagents-jade

Getting list of agents in container in jade


How can i get list of agents (their names like "da0@ip" etc.) in specified container in jade in java? I've looked and only thing i can find is a list of ALL agents in all containers. I'm not really into jade, it's just a school project so any advice would be helpful.


Solution

  • You can try to use AMS agent that is to send the request to it and handle responce. Something like:

    QueryAgentsOnLocation ca = new QueryAgentsOnLocation();
    ca.setLocation(...); // here is the information about you ontainer
    Action actExpr = new Action(myAgent.getAMS(), ca);
    
    ACLMessage request = new ACLMessage(ACLMessage.REQUEST);
    request.addReceiver(myAgent.getAMS());
    request.setOntology(JADEManagementOntology.getInstance().getName());
    request.setLanguage(FIPANames.ContentLanguage.FIPA_SL);
    request.setProtocol(FIPANames.InteractionProtocol.FIPA_REQUEST);
    myAgent.getContentManager().fillContent(request, actExpr);
    myAgent.send(request);