mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-15 20:12:04 +01:00
PingManager should notify PingFailedListeners only once
Fixes SMACK-548
This commit is contained in:
parent
a3e64bab18
commit
e7963b698d
1 changed files with 18 additions and 4 deletions
|
@ -215,13 +215,27 @@ public class PingManager {
|
||||||
* @return true if a reply was received from the server, false otherwise.
|
* @return true if a reply was received from the server, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean pingMyServer() {
|
public boolean pingMyServer() {
|
||||||
|
return pingMyServer(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pings the server. This method will return true if the server is reachable. It
|
||||||
|
* is the equivalent of calling <code>ping</code> with the XMPP domain.
|
||||||
|
* <p>
|
||||||
|
* Unlike the {@link #ping(String)} case, this method will return true even if
|
||||||
|
* {@link #isPingSupported(String)} is false.
|
||||||
|
*
|
||||||
|
* @param notifyListeners Notify the PingFailedListener in case of error if true
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean pingMyServer(boolean notifyListeners) {
|
||||||
Connection connection = weakRefConnection.get();
|
Connection connection = weakRefConnection.get();
|
||||||
boolean res = ping(connection.getServiceName());
|
boolean res = ping(connection.getServiceName());
|
||||||
if (!res) {
|
if (res) {
|
||||||
|
pongReceived();
|
||||||
|
} else if (notifyListeners) {
|
||||||
for (PingFailedListener l : pingFailedListeners)
|
for (PingFailedListener l : pingFailedListeners)
|
||||||
l.pingFailed();
|
l.pingFailed();
|
||||||
} else {
|
|
||||||
pongReceived();
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +337,7 @@ public class PingManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = pingMyServer();
|
res = pingMyServer(false);
|
||||||
// stop when we receive a pong back
|
// stop when we receive a pong back
|
||||||
if (res) {
|
if (res) {
|
||||||
lastSuccessfulAutomaticPing = System.currentTimeMillis();
|
lastSuccessfulAutomaticPing = System.currentTimeMillis();
|
||||||
|
|
Loading…
Reference in a new issue