quangmuop
2014-01-16 04:36:03 UTC
From the "ThanksAgent" example (in Jade package, I embeded this file in my
question), I create 1 more agent in the same container with agent 1, callagent 3. Then, I want to send message from agent 1 to agent 3, i add code
like here:
...../the code of ThanksAgent file/.....
public void action() {
//t1 send message to t3
String t1AgentName = getLocalName()+"t1";
String t3AgentName = getLocalName()+"t3";
ACLMessage tmsg = new
ACLMessage(ACLMessage.INFORM);
tmsg.setContent("Hello friend");
tmsg.addReceiver(new
AID(t3AgentName,AID.ISLOCALNAME));
myAgent.send(tmsg);
//reply from t3
ACLMessage rems = myAgent.receive();
if(rems!=null){
System.out.println(" - " +
myAgent.getLocalName() + " received: " + rems.getContent());
ACLMessage reply = new
ACLMessage(ACLMessage.INFORM);
//
reply.setPerformative(ACLMessage.INFORM);
reply.setContent("T3 reply!");
myAgent.send(reply);
}
block();
...../the code of ThanksAgent file/.....
but isnt doesnt work. I think the compiler doesnt distinct the variable
"myAgent" is belong to what agent, but I cant not use *t1.send(tmsg)* or
*t3.send(reply)*
Anyone can explain me how to solve the problem or edit the code above?
And one more question, how can I send message from agent 1 to agent 2, it
means how to send message between differ container and thank if give me an
example.
Thank you very much! ThanksAgent.java
<http://jade.17737.x6.nabble.com/file/n5002411/ThanksAgent.java>
--
View this message in context: http://jade.17737.x6.nabble.com/Question-about-the-ThanksAgent-example-in-Jade-pack-tp5002411.html
Sent from the JADE - Dev mailing list archive at Nabble.com.