powered by Jive Software

Sending packets from a plugin

Hi,

I am trying to create a plugin for openfire that creates packets and then sends them. how can I do this in openfire? I know how to intercept packets from a plugin and then either discard it or send it but don’t know how if I want to send packets.

any help would be appreciated.

thanks

Jack

Hi Jack,

You can send packets by simply doing the following:

XMPPServer.getInstance().getPacketRouter().route(packet);

Hope that helps,

Ryan

thanks Ryan

Jack

I have one more question regarding sending packets.

How would I know if the packet was not sent for whatever reason?

what happened to my packet if PacketRouter fails to deliver it?

Thanks,

Jack

It depends somewhat on what caused the failure. If an interceptor rejects it the message the router will try to be sent the packet back to the sender. Other failures such as sending the packet to a non-existent JID are difficult to detect. If guaranteed packet delivery is necessary you’ll probably have to create your own ACK implementation.

Cheers,

Ryan

Thanks Ryan.

Can you please elaborate a bit on how one can do the ACK implementation?

My plugin is supposed to send packets to an XMPP server and if that failed for

whatever reason like server is down the I need to try another server. The possible causes of

failure are really just two - one server is down and the other authentication fails.

Thanks,

Jack

Maybe I’m saying something fool but…as xmpp connection is build over a TCP protocol then you don’t have to worry about packet loss as if, for example, the other xmpp server is down you will get some kind of exception…