From 013f4d630a680633bd3a3f06fc70bab5439ec5d9 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 12 Nov 2016 11:03:44 +0100 Subject: [PATCH] Move duplicate code in AbstractXMPPConnection from XMPP(TCP|BOSH)Connection. --- .../org/jivesoftware/smack/bosh/XMPPBOSHConnection.java | 5 ----- .../org/jivesoftware/smack/AbstractXMPPConnection.java | 8 ++++++++ .../test/java/org/jivesoftware/smack/DummyConnection.java | 1 + .../org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 7 ------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java index cbc8a2654..0473359c6 100644 --- a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java +++ b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java @@ -198,11 +198,6 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection { + getHost() + ":" + getPort() + "."; throw new SmackException(errorMessage); } - - // Wait with SASL auth until the SASL mechanisms have been received - saslFeatureReceived.checkIfSuccessOrWaitOrThrow(); - - callConnectionConnectedListener(); } public boolean isSecureConnection() { diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index e76901474..c0a6d2ba1 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -369,6 +369,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { // Perform the actual connection to the XMPP service connectInternal(); + + // Wait with SASL auth until the SASL mechanisms have been received + saslFeatureReceived.checkIfSuccessOrWaitOrThrow(); + + // Make note of the fact that we're now connected. + connected = true; + callConnectionConnectedListener(); + return this; } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java b/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java index eb1e50647..662461224 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java @@ -90,6 +90,7 @@ public class DummyConnection extends AbstractXMPPConnection { @Override protected void connectInternal() { connected = true; + saslFeatureReceived.reportSuccess(); streamId = "dummy-" + new Random(new Date().getTime()).nextInt(); if (reconnect) { diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 8b336df7c..951abd602 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -885,13 +885,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // We connected successfully to the servers TCP port initConnection(); - - // Wait with SASL auth until the SASL mechanisms have been received - saslFeatureReceived.checkIfSuccessOrWaitOrThrow(); - - // Make note of the fact that we're now connected. - connected = true; - callConnectionConnectedListener(); } /**