mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-20 11:02:05 +01:00
Drop stream state after stream error
Fixes SMACK-696.
This commit is contained in:
parent
b1e4884fbb
commit
8aa3f94c90
1 changed files with 21 additions and 1 deletions
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.tcp;
|
||||
|
||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||
import org.jivesoftware.smack.AbstractXMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionConfiguration;
|
||||
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
|
||||
|
@ -295,6 +296,14 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
public XMPPTCPConnection(XMPPTCPConnectionConfiguration config) {
|
||||
super(config);
|
||||
this.config = config;
|
||||
addConnectionListener(new AbstractConnectionListener() {
|
||||
@Override
|
||||
public void connectionClosedOnError(Exception e) {
|
||||
if (e instanceof XMPPException.StreamErrorException) {
|
||||
dropSmState();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -402,7 +411,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
// connection instance though). This is used in writePackets to decide if stanzas should
|
||||
// be added to the unacknowledged stanzas queue, because they have to be added right
|
||||
// after the 'enable' stream element has been sent.
|
||||
unacknowledgedStanzas = null;
|
||||
dropSmState();
|
||||
}
|
||||
if (isSmAvailable() && useSm) {
|
||||
// Remove what is maybe left from previously stream managed sessions
|
||||
|
@ -1707,6 +1716,17 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop the stream management state. Sets {@link #smSessionId} and
|
||||
* {@link #unacknowledgedStanzas} to <code>null</code>.
|
||||
*/
|
||||
private void dropSmState() {
|
||||
// clientHandledCount and serverHandledCount will be reset on <enable/> and <enabled/>
|
||||
// respective. No need to reset them here.
|
||||
smSessionId = null;
|
||||
unacknowledgedStanzas = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum resumption time in seconds after which a managed stream can be resumed.
|
||||
* <p>
|
||||
|
|
Loading…
Reference in a new issue