aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/xmpp
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-05-18 11:25:04 +0200
committerDaniel Gultsch <daniel@gultsch.de>2014-05-18 11:25:04 +0200
commit0cdd74417fe98afbb184d83c8ff0a4fc248006de (patch)
treef59f392b11b638eddee6b505b750c8dafd6cc40a /src/eu/siacs/conversations/xmpp
parent66aacf7e3edae1e4a6ec6cab72df82ae38daa096 (diff)
fixed #53 aka server not found bug
Diffstat (limited to 'src/eu/siacs/conversations/xmpp')
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index 6e55ebfec..ab17d5d54 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -88,6 +88,8 @@ public class XmppConnection implements Runnable {
public long lastPingSent = 0;
public long lastConnect = 0;
public long lastSessionStarted = 0;
+
+ private int attempt = 0;
private static final int PACKET_IQ = 0;
private static final int PACKET_MESSAGE = 1;
@@ -113,6 +115,9 @@ public class XmppConnection implements Runnable {
if ((nextStatus == Account.STATUS_OFFLINE)&&(account.getStatus() != Account.STATUS_CONNECTING)&&(account.getStatus() != Account.STATUS_ONLINE)&&(account.getStatus() != Account.STATUS_DISABLED)) {
return;
}
+ if (nextStatus == Account.STATUS_ONLINE) {
+ this.attempt = 0;
+ }
account.setStatus(nextStatus);
if (statusListener != null) {
statusListener.onStatusChanged(account);
@@ -123,6 +128,7 @@ public class XmppConnection implements Runnable {
protected void connect() {
Log.d(LOGTAG,account.getJid()+ ": connecting");
lastConnect = SystemClock.elapsedRealtime();
+ this.attempt++;
try {
shouldAuthenticate = shouldBind = !account.isOptionSet(Account.OPTION_REGISTER);
tagReader = new XmlReader(wakeLock);
@@ -916,4 +922,14 @@ public class XmppConnection implements Runnable {
Log.d(LOGTAG,"adding "+jid+" to pending subscriptions");
this.pendingSubscriptions.add(jid);
}
+
+ public int getTimeToNextAttempt() {
+ int interval = (int) (25 * Math.pow(1.5,attempt));
+ int secondsSinceLast = (int) ((SystemClock.elapsedRealtime() - this.lastConnect) / 1000);
+ return interval - secondsSinceLast;
+ }
+
+ public int getAttempt() {
+ return this.attempt;
+ }
}