I'm quite new to Jade and multi agent systems. I'm trying to build a system with several agents who will have to communicate by sending ACLMessages. I've read documentation about the structure of how to build an Agent Class.
Here is my code:
public class ServerCommunicationAgent extends Agent {
public static String serverAddress = "http://LO-LESTER-077:8080";
private static final long serialVersionUID = 1L;
protected void setup() {
System.out.println(getLocalName() + ": correctly started");
boolean state = true;
// A Class that has a socket with my server
CommunicationService.getInstance().ServerCommunicationAgent(state);
// Sends a tick every millisecond
addBehaviour(new TickerBehaviour(this, 10000) {
private static final long serialVersionUID = 1L;
@Override
protected void onTick() {
ACLMessage message = new ACLMessage(ACLMessage.INFORM);
message.setContent("OK");
message.setLanguage("English");
message.setOntology("Test Dialogue");
message.setConversationId("TestID");
message.addReceiver(new AID("SecurityAgent", AID.ISLOCALNAME));
send(message);
}
});
}
// This method is called from CommunicationService when i have a response
public void LaunchServiceAgent(final String Agent, final String Location){
System.out.println(": Agent received service request: " + Agent + " in " + Location + " and has to call " + Agent + Location);
addBehaviour(new Behaviour(this) {
private static final long serialVersionUID = 1L;
@Override
public void action() {
ACLMessage messages = new ACLMessage(ACLMessage.INFORM);
messages.setContent("Hello world");
messages.setLanguage("English");
messages.setOntology("Test Dialogue");
messages.setConversationId("TestID");
messages.addReceiver(new AID(Agent + Location, AID.ISLOCALNAME));
send(messages);
}
@Override
public boolean done() {
return false;
}
});
}
So as i explained in my code, when the agent starts, it sends a message to my server. It receives a message through LaunchServiceAgent method. I correctly receive my message but i'm unable to send it to another agent using an ACLMessage. I think my code is correct because my TickBehaviour works fine.
So my question is, how do i correctly send a message to another Agent from my method?
Thanks for any response :)