powered by Jive Software

Listener priority

If there are multiple listeners registered to a “XMPPConnection” object, then how is the priority established ?.

I wrote a piece of code where I have

  1. A Packet listener e.g

XMPPConnection connection = new XMPPConnection(“host”);

connection.addPacketListener(packetListener, packetFilter);

  1. MessageListener e.g

XMPPConnection connection = new XMPPConnection(“host”);

Chat chat = connection.getChatManager().createChat(jid, new MessageListener() {
public void processMessage(Chat chat, Message message) {

}

  1. MessageEventNotificationListener e.g

XMPPConnection connection = new XMPPConnection(“host”);

MessageEventManager messageEventManager = new MessageEventManager(connection) {

messageEventManager.addMessageEventNotificationListener(new MessageEventNotificationListener() {
public void deliveredNotification(String from, String packetID) { }

public void displayedNotification(String from, String packetID) { }

public void composingNotification(String from, String packetID) { }

public void offlineNotification(String from, String packetID) { }

public void cancelledNotification(String from, String packetID) { }

}

The actual behaviour that I am noticing is …

MessageEventNotificationListener is not getting fired at all.

MessageListener is getting triggered and I am able to pick up the MessageEvent by performing a message.getExtension()

PacketListener is also getting triggered and I can pick up the MessageEvent by doing casting Packet to Message, followed up by

message.getExtension().

So, in effect both listeners (Message and Packet) are getting triggered and I would be curious to see how priority can be established. \

/rk