be more careful to avoid creating multiple connections

This commit is contained in:
Daniel Gultsch 2016-03-20 17:24:41 +01:00
parent b51ce43d36
commit 7df24407dc
2 changed files with 8 additions and 3 deletions

View file

@ -2578,6 +2578,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
Thread thread = new Thread(connection);
connection.setInteractive(interactive);
connection.prepareNewConnection();
thread.start();
scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
} else {

View file

@ -219,12 +219,16 @@ public class XmppConnection implements Runnable {
}
}
public void prepareNewConnection() {
this.lastConnect = SystemClock.elapsedRealtime();
this.lastPingSent = SystemClock.elapsedRealtime();
this.lastDiscoStarted = Long.MAX_VALUE;
this.changeStatus(Account.State.CONNECTING);
}
protected void connect() {
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": connecting");
features.encryptionEnabled = false;
lastConnect = SystemClock.elapsedRealtime();
lastPingSent = SystemClock.elapsedRealtime();
lastDiscoStarted = Long.MAX_VALUE;
this.attempt++;
switch (account.getJid().getDomainpart()) {
case "chat.facebook.com":