[Pogamut-list] listener working example

jcothran pogamut-forum at artemis.ms.mff.cuni.cz
Tue Jun 16 02:50:58 CEST 2009


listener working example

Author: jcothran

I'm trying to implement just a test listener from examples listed at the following links

*logs and messages section
http://artemis.ms.mff.cuni.cz/pogamut/tiki-index.php?page=Agent+tutorial

*earlier forum post
http://artemis.ms.mff.cuni.cz/pogamut/tiki-view_forum_thread.php?comments_parentId=539&topics_offset=5&forumId=6

but I can't get my listener to log any events when I test it???

Does anyone have a basic listener example main.java that works or can tell me what I'm doing wrong in the below code ?

Thanks much,
Jeremy

*main.java

package advancedbot;

import cz.cuni.pogamut.Client.Agent;
import cz.cuni.pogamut.Client.RcvMsgEvent;
import cz.cuni.pogamut.Client.RcvMsgListener;
import cz.cuni.pogamut.exceptions.PogamutException;
import cz.cuni.pogamut.introspection.PogProp;
import java.io.IOException;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import cz.cuni.pogamut.MessageObjects.*;
import cz.cuni.pogamut.exceptions.ConnectException;

/**
 * This bot will show you how to shoot down your opponets, it's extension
 * of the SimpleBot ... it just checks whether it sees an opponent and 
 * if so - shoot him down.
 * 
 * @author Horatko
 */
public class Main extends Agent {
    private RcvMsgListener ChatListener;

    public Main() {}

    NavPoint chosenNavigationPoint = null;
    Player enemy = null;

 // this class could handle the messages. It should be contained in Agent class
protected class ChatListener implements RcvMsgListener{

  @Override
  public void receiveMessage(RcvMsgEvent e) {   
      //MessageObject temp = e.getMessage();
  //log.info("He said that "+((GlobalChat) temp).toString());
  log.info("He said that - test");
  }

}

@Override
protected void postPrepareAgent(){
body.addTypedRcvMsgListener(ChatListener, MessageType.GLOBAL_CHAT);
}

...(rest of usual DoLogic, etc)





More information about the Pogamut-list mailing list