Question about receiving messages using SMACK with ejabberd

All,

I have what seems to be a stupid question. I thave two users, usera and userb. Usera sends messages to userb but userb does not receive them (the processMessage method is not invoked).

After connecting both users create a chat and reference the other user and specify the MessageListener object.

Example:

// username = “usera”|“userb” + “domain.com

// port is the default 5222

String [] location = username.split("@");
ConnectionConfiguration config = new ConnectionConfiguration(hostname,
port,
location[1]);
config.setSASLAuthenticationEnabled(true);
theConnection = new XMPPConnection(config);
theConnection.connect();
theConnection.login(location[0], password);
theConnection.getChatManager().createChat(((location[0].equals(“usera”)) ? “userb” : “usera”)+ “@” +location[1],
new MessageListener() {

     @Override
     public void processMessage (Chat chat, Message msg) {

System.out.println(msg.getBody());

}

});

It did not make sence so I enabled debugging. Once I did this I could see where userb was receiving messages but it did not appear to be invoking the method (nothing is printed to the terminal).

I am using the latest SMACK API (retrieved from svn 11/10/10). I cannot use the official 3.1.0 release because it will not connect to ejabberd (even with patch 264). If 264 is applied then the connect() will succeded but the login will fail (something about no response from the server).

Am I missing something when creating the Chat?

Thanks,

Scott

Message was edited by: Scott

UPDATE:

Found the answer at: http://davanum.wordpress.com/2007/12/31/android-just-use-smack-api-for-xmpp/. I must say that the answer is not obvious for someone new. It would be nice if there was an ‘addMessageListener(MessageListener)’ method in the XMPPConnection class. And of course add this to the examples in the documentation. It seems like receiving a message is completely skipped over.

Thanks,

Scott