diff options
author | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-06 19:46:52 +0100 |
---|---|---|
committer | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-06 19:46:52 +0100 |
commit | f02f510c187a581afd27093c97eb421fc56d3221 (patch) | |
tree | 58562a67b94aa1e409addb4693632c0df0909ceb /src/main/java | |
parent | 353f4e38bb065dacd8c8c16872b205aa0ca02f92 (diff) |
fixed bug in new ping strategy
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 1192d5b9..cf3f72dc 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -421,16 +421,16 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa long lastReceived = account.getXmppConnection().getLastPacketReceived(); long lastSent = account.getXmppConnection().getLastPingSent(); long pingInterval = "ui".equals(action) ? Config.PING_MIN_INTERVAL * 1000 : Config.PING_MAX_INTERVAL * 1000; - long secondsToNextPing = ((lastReceived + pingInterval) - SystemClock.elapsedRealtime()) / 1000; + long msToNextPing = (Math.max(lastReceived,lastSent) + pingInterval) - SystemClock.elapsedRealtime(); if (lastSent > lastReceived && (lastSent + Config.PING_TIMEOUT * 1000) < SystemClock.elapsedRealtime()) { Log.d(Config.LOGTAG, account.getJid().toBareJid()+ ": ping timeout"); this.reconnectAccount(account, true); - } else if (secondsToNextPing <= 0) { + } else if (msToNextPing <= 0) { account.getXmppConnection().sendPing(); Log.d(Config.LOGTAG, account.getJid().toBareJid()+" send ping"); this.scheduleWakeUpCall(Config.PING_TIMEOUT,account.getUuid().hashCode()); } else { - this.scheduleWakeUpCall((int) secondsToNextPing, account.getUuid().hashCode()); + this.scheduleWakeUpCall((int) (msToNextPing / 1000), account.getUuid().hashCode()); } } else if (account.getStatus() == Account.State.OFFLINE) { if (account.getXmppConnection() == null) { |