From 7df24407dcbe6b19af7996cc0752531958c133d2 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 20 Mar 2016 17:24:41 +0100 Subject: be more careful to avoid creating multiple connections --- .../eu/siacs/conversations/services/XmppConnectionService.java | 1 + src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 10 +++++++--- 2 files changed, 8 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 ecf5504b..99f2e09a 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -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 { diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 72996e4b..fd0e355d 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -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": -- cgit v1.2.3