1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 08:12:05 +01:00

Reset carbons state on clean disconnect

and if session was not resumed. Fixes SMACK-688.
This commit is contained in:
Florian Schmaus 2015-07-31 13:27:03 +02:00
parent 8db082e5ea
commit 8c6e56b122

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.carbons;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -65,6 +66,22 @@ public class CarbonManager extends Manager {
super(connection); super(connection);
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
sdm.addFeature(CarbonExtension.NAMESPACE); sdm.addFeature(CarbonExtension.NAMESPACE);
connection.addConnectionListener(new AbstractConnectionListener() {
@Override
public void connectionClosed() {
// Reset the state if the connection was cleanly closed. Note that this is not strictly necessary,
// because we also reset in authenticated() if the stream got not resumed, but for maximum correctness,
// also reset here.
enabled_state = false;
}
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {
if (!resumed) {
// Non-resumed XMPP sessions always start with disabled carbons
enabled_state = false;
}
}
});
} }
/** /**