/** * Section 5.2.4 pag. 97 * * This class implements a simple message receiver behaviour: * it receives a message and puts it into the DataStore **/ import jade.core.behaviours.SimpleBehaviour; import jade.core.behaviours.DataStore; import jade.lang.acl.ACLMessage; public class MessageReceiver extends SimpleBehaviour { /** This constant should be used to get the received message from the DataStore **/ public static final String RECV_MSG = "received-message"; private boolean finished = false; public void action() { ACLMessage msg = myAgent.receive(); if (msg!= null) { getDataStore().put(RECV_MSG, msg); finished = true; } else { block(); } } public boolean done() { return finished; } }