How to intercept a Ping message from an Openfire server?
I am writing an Openfire plugin to intercept a Ping message that the server sends to the client when the client goes to sleep. The ping system looks like this:
<iq from='capulet.lit' to='juliet@capulet.lit/balcony' id='s2c1' type='get'>
<ping xmlns='urn:xmpp:ping'/>
</iq>
However, when I use PacketInterceptor to intercept all packets between server and clients, the interceptor can intercept all EXCEPT packets for Ping. I do not understand what is going on. Any help is appreciated!
+3
source to share
2 answers
Here you can find the simplest example of a batch interceptor that logs every incoming and outgoing packet. http://faisalbhagat.blogspot.com/2014/03/openfire-logging-using-packetinterceptor.html
+1
source to share
Below is the override method intercepPacket
in my plugin, it can intercept the ping message. For reference ~ :)
@Override
public void interceptPacket(org.xmpp.packet.Packet packet, Session session,
boolean incoming, boolean processed) throws PacketRejectedException {
if (incoming && !processed) {
String packetXml = packet.toXML();
logger.warn("\n" + new XmlFormatter().format(packetXml));
}
}
0
source to share