문제

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?

도움이 되었습니까?

해결책

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(
    "serviceJID@server.org",
    success_callback,
    error_callback,
    timeout
);

```

In the error_callback you can determine if timeout was reached and then reconnect to your XMPP server.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top