1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-06-23 03:54:54 +02:00

Merge pull request #296 from MarcelHeckel/PingManager_ConnectionOkOnAnyPacket

PingManager: con. assumed ok for any packed within the ping interval
This commit is contained in:
Florian Schmaus 2019-03-20 20:00:54 +01:00 committed by GitHub
commit 989dbb14e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -447,6 +447,19 @@ public final class PingManager extends Manager {
pingFuture.onError(new ExceptionCallback<Exception>() {
@Override
public void processException(Exception exception) {
long lastStanzaReceived = connection.getLastStanzaReceived();
if (lastStanzaReceived > 0) {
long now = System.currentTimeMillis();
// Delta since the last stanza was received
int deltaInSeconds = (int) ((now - lastStanzaReceived) / 1000);
// If the delta is smaller then the ping interval, we have got an valid stanza in time
// So not error notification needed
if (deltaInSeconds < pingInterval) {
maybeSchedulePingServerTask(deltaInSeconds);
return;
}
}
for (PingFailedListener l : pingFailedListeners) {
l.pingFailed();
}