/***************************************************************** Ping.java: Agent which answers all messages with a "Pong" -------------- Author: Jean Vaucher Date: Aug 10 2003 *****************************************************************/ import jade.core.Agent; import jade.core.behaviours.*; import jade.lang.acl.*; public class Ping extends Agent { protected void setup() { addBehaviour(new CyclicBehaviour(this) { public void action() { ACLMessage msg = receive(); if (msg!=null) { System.out.println( " - " + myAgent.getLocalName() + " <- " + msg.getContent() ); ACLMessage reply = msg.createReply(); reply.setPerformative( ACLMessage.INFORM ); reply.setContent(" Pong" ); send(reply); } block(); } }); } }