reuse same xmppconnection for reconnects
This commit is contained in:
parent
41ae4af1b8
commit
7b1efe15cd
|
@ -2451,11 +2451,14 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
|
|
||||||
private void reconnectAccount(final Account account, final boolean force, final boolean interactive) {
|
private void reconnectAccount(final Account account, final boolean force, final boolean interactive) {
|
||||||
synchronized (account) {
|
synchronized (account) {
|
||||||
if (account.getXmppConnection() != null) {
|
XmppConnection connection = account.getXmppConnection();
|
||||||
|
if (connection != null) {
|
||||||
disconnect(account, force);
|
disconnect(account, force);
|
||||||
|
} else {
|
||||||
|
connection = createConnection(account);
|
||||||
|
account.setXmppConnection(connection);
|
||||||
}
|
}
|
||||||
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
|
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
|
||||||
|
|
||||||
synchronized (this.mInProgressAvatarFetches) {
|
synchronized (this.mInProgressAvatarFetches) {
|
||||||
for (Iterator<String> iterator = this.mInProgressAvatarFetches.iterator(); iterator.hasNext(); ) {
|
for (Iterator<String> iterator = this.mInProgressAvatarFetches.iterator(); iterator.hasNext(); ) {
|
||||||
final String KEY = iterator.next();
|
final String KEY = iterator.next();
|
||||||
|
@ -2464,10 +2467,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!force) {
|
||||||
if (account.getXmppConnection() == null) {
|
|
||||||
account.setXmppConnection(createConnection(account));
|
|
||||||
} else if (!force) {
|
|
||||||
try {
|
try {
|
||||||
Log.d(Config.LOGTAG, "wait for disconnect");
|
Log.d(Config.LOGTAG, "wait for disconnect");
|
||||||
Thread.sleep(500); //sleep wait for disconnect
|
Thread.sleep(500); //sleep wait for disconnect
|
||||||
|
@ -2475,13 +2475,13 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
//ignored
|
//ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Thread thread = new Thread(account.getXmppConnection());
|
Thread thread = new Thread(connection);
|
||||||
account.getXmppConnection().setInteractive(interactive);
|
connection.setInteractive(interactive);
|
||||||
thread.start();
|
thread.start();
|
||||||
scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
|
scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
|
||||||
} else {
|
} else {
|
||||||
account.getRoster().clearPresences();
|
account.getRoster().clearPresences();
|
||||||
account.setXmppConnection(null);
|
connection.resetEverything();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -875,6 +875,14 @@ public class XmppConnection implements Runnable {
|
||||||
+ instructions);
|
+ instructions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetEverything() {
|
||||||
|
resetStreamId();
|
||||||
|
clearIqCallbacks();
|
||||||
|
synchronized (this.disco) {
|
||||||
|
disco.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void sendBindRequest() {
|
private void sendBindRequest() {
|
||||||
while(!mXmppConnectionService.areMessagesInitialized() && socket != null && !socket.isClosed()) {
|
while(!mXmppConnectionService.areMessagesInitialized() && socket != null && !socket.isClosed()) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue