To realize the communication of agents on different machines in the local area network, two problems need to be paid attention to:
1. The protocol about file and printer sharing within the firewall must be opened to ensure the resolution of the machine name.
2. When the communication aclmessage add receiver when the designated legal aid, this aid must have the full name, the second must have the legal addresses.
Like the following example
import Jade.core.AID;
import jade.domain.AMSService;
Import jade.domain.fipaagentmanagement.*;
public class Sender2 extends Agent {
protected void Setup ()
{
amsagentdescription [] agents = nul L
Aid rams= New Aid ("Ams@gjpc:1099/jade");//Get AMS on GJPC machine
rams.addaddresses ("Http://gjpc:7778/acc");
try {
Searchconstraints c = new searchconstraints ();
C.setmaxresults (New Long (-1));
//agents = Amsservice.search (This, new Amsagentdescription (), c);
//below find Rams inside agents
Agents = Amsservice.search (this, Rams, New Amsagentdescription (), c);
catch (Exception e) {
System.out.println ("Problem searching AMS:" + e);
E.printstacktrace ();
}
Aclmessage msg = new Aclmessage (aclmessage.inform);
Msg.setcontent ("This is the Guojie ' Ping");//local machine name is Guojie
//send messages to them one by one
for (int i=0; I<agents.length;i++) {
if (Agents[i].getname (). Equals (Getaid ())) {
Continue;
System.out.println (Agents[i].getname (). toString ());
Agents[i].getname (). Addaddresses ("Http://gjpc:7778/acc");
//This sentence must have
Msg.addreceiver (Agents[i].getname ());
}
System.out.println ("Wait fro a minute ...");
Send (msg);
}
}