PacketExtensionFilter problem

I created a custom PacketExtensionFilter with my own namespace, as well as an IQProvider which I added to smack.providers. This all works fine. My problem is simply that I can’'t use a PacketExtensionFilter to filter my incoming custom IQ packets because for some reason, the Packet object that is passed into the accept(Packet) method of the filter contains an empty List of PacketExtensions. However, packet.toXML() reveals a packet like the following:

<iq type="result" id="X56Vp-4" from="conference.jsegal" to="user1@jsegal/Smack">
  <query xmlns="http://jabber.org/protocol/disco#mymucs">
       <muc ...></muc>
       <muc ...></muc>
  </query>
</iq>

So, my filter which looks like

new PacketExtensionFilter("query", "http://jabber.org/protocol/disco#mymucs")

does not accept the Packet since it appears to have no extensions whatsoever.

Am I missing something or is this expected behavior?

Thanks,

Jeff

Hey Jeff,

Child elements of IQ packets are not considered packet extensions. That is why the filter is not catching IQ responses. Instead you may want to use PacketIDFilter (combined with a PacketCollector) so that you can catch the exact answer to an IQ packet that you sent.

Regards,

– Gato

Gato,

Thanks for the help. Just wanted to post a follow-up to this for future reference. A minute ago I was confused as to how the client would know what ID to expect the result IQ packet to contain. However, I see now that it’'s not a problem at all since the result IQ packet must have the same ID as the querying IQ packet, which presumably the client would be issuing itself.

Hope this helps someone!

Jeff

Hey Jeff,

That is exactly right. You can look for PacketIDFilter references to see

how it is being used.

Regards,

– Gato

Okay. What about the case where a Smack-based client needs to respond to an IQ. For example, a client implementing “jabber:iq:time” must filter and listen for IQ’'s of that type. As it is the respondent and not the requester, it will not know what the ID will be, so PacketIDFilter will not work. I did not see an obvious filter to use for that case.

Thx

Message was edited by: mrpantsuit