package communication.ex03_replyingToMessages;
import static communication.ex01.Society.COMMUNITY;
import static communication.ex01.Society.GROUP;
import static communication.ex01.Society.ROLE;
import communication.ex01.PingAgent;
import madkit.kernel.Madkit;
import madkit.kernel.Message;
import madkit.message.StringMessage;
public class ReplierAgent extends PingAgent {
@Override
protected void live() {
while (sendMessage(COMMUNITY, GROUP, ROLE, new Message()) != ReturnCode.SUCCESS) {
pause((int) (Math.random() * 1000 + 100));
}
Message m = nextMessage();
if (m != null) {
getLogger().info("I have to thank " + m.getSender());
sendReply(m, new StringMessage("thanks"));
}
pause(10000);
}
@SuppressWarnings("unused")
public static void main(String[] args) {
new Madkit("--launchAgents", ReplierAgent.class.getName() + ",true,10;", PingAgent.class.getName() );
}
}