mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
Merge pull request #416 from Flowdalic/connected-boolean
Set 'connected' to 'true' as early as possible
This commit is contained in:
commit
cf92566e26
4 changed files with 15 additions and 2 deletions
|
@ -522,6 +522,9 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
closingStreamReceived = false;
|
closingStreamReceived = false;
|
||||||
streamId = null;
|
streamId = null;
|
||||||
|
|
||||||
|
// The connection should not be connected nor marked as such prior calling connectInternal().
|
||||||
|
assert !connected;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Perform the actual connection to the XMPP service
|
// Perform the actual connection to the XMPP service
|
||||||
connectInternal();
|
connectInternal();
|
||||||
|
@ -537,8 +540,9 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make note of the fact that we're now connected.
|
// If connectInternal() did not throw, then this connection must now be marked as connected.
|
||||||
connected = true;
|
assert connected;
|
||||||
|
|
||||||
callConnectionConnectedListener();
|
callConnectionConnectedListener();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -217,6 +217,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
@Override
|
@Override
|
||||||
public void setTransport(XmppClientToServerTransport xmppTransport) {
|
public void setTransport(XmppClientToServerTransport xmppTransport) {
|
||||||
ModularXmppClientToServerConnection.this.activeTransport = xmppTransport;
|
ModularXmppClientToServerConnection.this.activeTransport = xmppTransport;
|
||||||
|
ModularXmppClientToServerConnection.this.connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -116,5 +116,11 @@ public abstract class ModularXmppClientToServerConnectionInternal {
|
||||||
|
|
||||||
public abstract void setCompressionEnabled(boolean compressionEnabled);
|
public abstract void setCompressionEnabled(boolean compressionEnabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the active transport (TCP, BOSH, WebSocket, …) to be used for the XMPP connection. Also marks the connection
|
||||||
|
* as connected.
|
||||||
|
*
|
||||||
|
* @param xmppTransport the active transport.
|
||||||
|
*/
|
||||||
public abstract void setTransport(XmppClientToServerTransport xmppTransport);
|
public abstract void setTransport(XmppClientToServerTransport xmppTransport);
|
||||||
}
|
}
|
||||||
|
|
|
@ -836,6 +836,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
// there is an error establishing the connection
|
// there is an error establishing the connection
|
||||||
connectUsingConfiguration();
|
connectUsingConfiguration();
|
||||||
|
|
||||||
|
connected = true;
|
||||||
|
|
||||||
// We connected successfully to the servers TCP port
|
// We connected successfully to the servers TCP port
|
||||||
initConnection();
|
initConnection();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue