powered by Jive Software

Help implementing a custom <iq> packet

I’ve read the bits of documentation that are on the site and I’m not entirely clear how to go about implementing a custom iq.

So far, I have extended the IQ type, written a provider and bound the provider to the ProviderManager. I can send the packet ok, and receive it in a PacketListener but I’m not sure what is supposed to happen then.

Do I manually populate another IQ response type and send it back? Is that all there is to it?

I believe that your correct. You recieve the IQ packet, you do the actions associated with recieving the packet, and then you send the response. Done.

You have done the correct thing so far. As to what you do afterwords, that depends on the nature of the original IQ packet. If it requested a form for example, then you would receive the form and can reply to it (using existing code). If it is something completely unsupported in Smack, then you will have to do all the handling yourself. This is what I had to do to add pubsub support.

In addition to the custom provider for a IQ packet, you can also create custom providers and PacketExtensions for the extensions embedded within the IQ packet.

You can look up the pubsub IQ packet as and example as well as the many extensions. I also added the template method pattern using the EmbeddedExtensionProvider to simplfy parsing the extensions.