mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-24 15:22:07 +01:00
[tcp] Set sync points before they are used, and not in init()
This commit is contained in:
parent
843c8dd7fe
commit
fd1b49ca8f
1 changed files with 6 additions and 9 deletions
|
@ -364,6 +364,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
SmackException, IOException, InterruptedException {
|
SmackException, IOException, InterruptedException {
|
||||||
// Authenticate using SASL
|
// Authenticate using SASL
|
||||||
SSLSession sslSession = secureSocket != null ? secureSocket.getSession() : null;
|
SSLSession sslSession = secureSocket != null ? secureSocket.getSession() : null;
|
||||||
|
|
||||||
|
streamFeaturesAfterAuthenticationReceived = false;
|
||||||
authenticate(username, password, config.getAuthzid(), sslSession);
|
authenticate(username, password, config.getAuthzid(), sslSession);
|
||||||
|
|
||||||
// Wait for stream features after the authentication.
|
// Wait for stream features after the authentication.
|
||||||
|
@ -375,6 +377,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
// recommends to perform stream compression before resource binding.
|
// recommends to perform stream compression before resource binding.
|
||||||
maybeEnableCompression();
|
maybeEnableCompression();
|
||||||
|
|
||||||
|
smResumedSyncPoint = SyncPointState.initial;
|
||||||
|
smResumptionFailed = null;
|
||||||
if (isSmResumptionPossible()) {
|
if (isSmResumptionPossible()) {
|
||||||
smResumedSyncPoint = SyncPointState.request_sent;
|
smResumedSyncPoint = SyncPointState.request_sent;
|
||||||
sendNonza(new Resume(clientHandledStanzasCount, smSessionId));
|
sendNonza(new Resume(clientHandledStanzasCount, smSessionId));
|
||||||
|
@ -409,6 +413,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
// unacknowledgedStanzas and become duplicated on reconnect. See SMACK-706.
|
// unacknowledgedStanzas and become duplicated on reconnect. See SMACK-706.
|
||||||
bindResourceAndEstablishSession(resource);
|
bindResourceAndEstablishSession(resource);
|
||||||
|
|
||||||
|
smEnabledSyncPoint = false;
|
||||||
if (isSmAvailable() && useSm) {
|
if (isSmAvailable() && useSm) {
|
||||||
// Remove what is maybe left from previously stream managed sessions
|
// Remove what is maybe left from previously stream managed sessions
|
||||||
serverHandledStanzasCount = 0;
|
serverHandledStanzasCount = 0;
|
||||||
|
@ -535,15 +540,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
initState();
|
initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initState() {
|
|
||||||
super.initState();
|
|
||||||
streamFeaturesAfterAuthenticationReceived = compressSyncPoint = false;
|
|
||||||
smResumedSyncPoint = SyncPointState.initial;
|
|
||||||
smResumptionFailed = null;
|
|
||||||
smEnabledSyncPoint = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendNonza(Nonza element) throws NotConnectedException, InterruptedException {
|
public void sendNonza(Nonza element) throws NotConnectedException, InterruptedException {
|
||||||
packetWriter.sendStreamElement(element);
|
packetWriter.sendStreamElement(element);
|
||||||
|
@ -794,6 +790,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
// If stream compression was offered by the server and we want to use
|
// If stream compression was offered by the server and we want to use
|
||||||
// compression then send compression request to the server
|
// compression then send compression request to the server
|
||||||
if ((compressionHandler = maybeGetCompressionHandler(compression)) != null) {
|
if ((compressionHandler = maybeGetCompressionHandler(compression)) != null) {
|
||||||
|
compressSyncPoint = false;
|
||||||
sendNonza(new Compress(compressionHandler.getCompressionMethod()));
|
sendNonza(new Compress(compressionHandler.getCompressionMethod()));
|
||||||
waitForConditionOrThrowConnectionException(() -> compressSyncPoint, "establishing stream compression");
|
waitForConditionOrThrowConnectionException(() -> compressSyncPoint, "establishing stream compression");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue