How do I receive XMPP chat messages that are sent to a different resource?
E.g. my message listener receives messages fine, until that message gets replied to from another resource (like Gmail Google Talk). From that point on the messages are sent to that client resource and not my listener.
I'm using the Smack library for Java (well, actually asmack which is a port for Android)
After connecting to the service (Google Talk server), I add a listener like this:
connection.addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
Log.i(TAG, "processPacket: chat");
Message message = (Message) packet;
Log.d(TAG, "Message: " + message.toXML());
if (message.getBody() != null) {
String fromName = StringUtils.parseBareAddress(message.getFrom());
Log.i(TAG, "Got text [" +
message.getBody() +
"] from [" +
fromName +
"]");
}
}
}, filter);
This works fine initially, I receive messages from Google Talk. These messages actually get sent to multiple clients, my desktop Google Talk, the Google Talk app an Android, and my implementation.
But when I reply to a message, say in the desktop application, all subsequent messages get sent to the desktop application resource, and I get nothing received in my implementation.
So I'm not sure how to also receive these messages. The Google Talk application seems to do this. It doesn't appear as a new message like it does initially (before it's replied to), but it does get updated in the Google Talk application thread.
Any help would be great!