mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +01:00
Reset carbons state on clean disconnect
and if session was not resumed. Fixes SMACK-688.
This commit is contained in:
parent
8db082e5ea
commit
8c6e56b122
1 changed files with 17 additions and 0 deletions
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue