1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 05:52:06 +01: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>() { pingFuture.onError(new ExceptionCallback<Exception>() {
@Override @Override
public void processException(Exception exception) { 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) { for (PingFailedListener l : pingFailedListeners) {
l.pingFailed(); l.pingFailed();
} }