/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package B; import jade.core.Agent; import jade.core.behaviours.*; import jade.lang.acl.*; /** * * @author TRSteep */ public class BClass extends Agent { protected void setup() { System.out.println("Привет! агент "+getAID().getName()+" готов."); addBehaviour(new CyclicBehaviour(this) { public void action() { ACLMessage msg = receive(); if (msg != null) { System.out.println(" – " + myAgent.getLocalName() + " received: " + msg.getContent() ); //Вывод на экран локального имени агента и полученного сообщения ACLMessage reply = msg.createReply(); reply.setPerformative( ACLMessage.INFORM ); //set the performative of this ACL message object to the passed constant. Remind to use the set of constants (i.e. INFORM, REQUEST, … ) defined in this class reply.setContent( "Pong"); //Содержимое сообщения send(reply);//отправляем сообщения } block(); } }); } }