mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03: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:
commit
989dbb14e8
1 changed files with 13 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue