Jabber-Net icon indicating copy to clipboard operation
Jabber-Net copied to clipboard

XEP-0199: XMPP Ping

Open ForNeVeR opened this issue 8 years ago • 3 comments
trafficstars

Add support for XEP-0199: XMPP Ping. If the server couldn't answer ping for some specified amount of time, disconnect from the server and ensure client gets notified.

ForNeVeR avatar Jan 18 '17 05:01 ForNeVeR

See also: http://stackoverflow.com/questions/23863703/how-to-send-ping-packets-using-jabber-net-library — Joe himself have answered a similar question.

ForNeVeR avatar Jan 18 '17 06:01 ForNeVeR

Thank you for the references. I know only the basics of the XMPP protocol, I'm trying to learn it. How can I use the PingQuery class of the stackoverflow answer to send a ping to the server and then receiving it? I googled it without any success.

toledomatias avatar Jan 18 '17 16:01 toledomatias

Sorry, it's been long since I last used IQ sending, but I'll try to help. Look: JabberClient is derived from XmppStream that has a Tracker property.

I believe that the main usage pattern looks like that:

client.Tracker.BeginIQ(new PingIQ(client.Document), (sender, iq, data) => {
    /* handle ping response */
}, null);

You could call it periodically and reconnect if the answer from the server wasn't received for some timeout.

On how to construct PingIQ type (Joe donesn't mention that), please consult AuthIQ class. It seems that you should create a type derived from generic jabber.protocol.client.TypedIQ<PingQuery> (where PingQuery is a type from Joe's example).

ForNeVeR avatar Jan 19 '17 03:01 ForNeVeR