Sending another packet from an IQ Handler

Within an IQ Handler I’‘m developing, there’‘s a need to send another packet to a few users, apart from the standard reply packet returned to the IQ origin. There could be up to 9-10 packets I need to send to different JID’'s before returnig the reply packet.

So far I was using the following steps to send those extra packets:

  1. Create myPacket.

  2. iqRouter = XMPPServer.getInstance().getIQRouter();

  3. iqRouter.route(myPacket);

Is this the best way to do this? Am I asking for trouble or performance issues?

Thanks.

Hey Alex,

That is the exact code you have to use. When creating new packets and sending them you should use a router to route them. The router will invoke the corresponding packet interceptors and route the packet accordingly. If you instead try to find the target session by yourself and send the packet then you will be skipping some required logic unless you have some good reason for doing that which is not recommended.

Regards,

– Gato

Thanks, I saw it was working fine so far but I wanted to make sure.

Would you recommend using another thread to route those other packets?

Hey Alex,

I think using the current thread is fine. Delivering packets to clients is done by another thread. So your current thread will just queue the packet for delivery and MINA will do the actual delivery for you. In other words, delivery of packets is asynchronous.

Regards,

– Gato