powered by Jive Software

PacketListener not triggered without <body>

Hey guys,

I implemented a custom PacketListener and registered it on a MultiUserChat by calling addMessageListener(). It works fine and processPacket() is called if I receive a standard groupchat message. If however I receive a message that does not contain a <body> (I’m implementing a custom protocoll contained as an <x> extension), processPacket() is not called.

Is that expected behaviour? If so, is there a mechanism to listen for messages without a <body>?

thx in advance



This is what you can find in MultiUserChat.java:

messageFilter =

new AndFilter(

new FromMatchesFilter(room),

new MessageTypeFilter(Message.Type.groupchat));

messageFilter = new AndFilter(messageFilter, new PacketFilter() {

public boolean accept(Packet packet) {

Message msg = (Message) packet;

return msg.getBody() != null;



public void addMessageListener(PacketListener listener) {

connection.addPacketListener(listener, messageFilter);



As you can see, the packets are filtered so that only the messages with a body content are accepted. In order to be able to accept your custom packets you need to add you packet listener directly to your connection object with an appropriate filter and not use the addMessageListener in MUC.

Hey Pawel,

thanks for your help!

I will check out http://www.igniterealtime.org/builds/smack/docs/latest/javadoc/org/jivesoftware/ smack/Connection.html#addPacketListener(org.jivesoftware.smack.PacketListener,%2 0org.jivesoftware.smack.filter.PacketFilter)!