I want to do a background check, which will be every minute to check the Internet connection. If it interrupted then I show a message and try to reconnect. How do I do this?
1
votes
1 Answers
2
votes
Sounds like you want to implement XMPP Ping (XEP-0199).
There is a Strophe plugin for this: https://github.com/strophe/strophejs-plugins/tree/master/ping
You ping the server, and then provide a callback for a successful response and a callback for when an error occurs or when the timeout was reached.
```
connection.ping.ping(
"[email protected]",
success_callback,
error_callback,
timeout
);
```
In the error_callback
you can determine if timeout was reached and then reconnect to your XMPP server.