Skip to content

Commit

Permalink
smackable: connect after adding connlistener. fix breakage on first conn
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0rg committed Jul 30, 2014
1 parent 40f0f4a commit 5ae17bc
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/org/yaxim/androidclient/service/SmackableImp.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,6 @@ private void tryToConnect(boolean create_account) throws YaximXMPPException {
registerRosterListener();
boolean need_bind = !mStreamHandler.isResumePossible();

mXMPPConnection.connect(need_bind);
// the following should not happen as of smack 3.3.1
if (!mXMPPConnection.isConnected()) {
throw new YaximXMPPException("SMACK connect failed without exception!");
}
if (mConnectionListener != null)
mXMPPConnection.removeConnectionListener(mConnectionListener);
mConnectionListener = new ConnectionListener() {
Expand All @@ -531,6 +526,7 @@ public void reconnectionSuccessful() { }
};
mXMPPConnection.addConnectionListener(mConnectionListener);

mXMPPConnection.connect(need_bind);
// SMACK auto-logins if we were authenticated before
if (!mXMPPConnection.isAuthenticated()) {
if (create_account) {
Expand All @@ -547,8 +543,6 @@ public void reconnectionSuccessful() { }
setStatusFromConfig();
}

} catch (YaximXMPPException e) {
throw e;
} catch (Exception e) {
// actually we just care for IllegalState or NullPointer or XMPPEx.
throw new YaximXMPPException("tryToConnect failed", e);
Expand Down

0 comments on commit 5ae17bc

Please sign in to comment.