1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Add 'resumed' bool ConnectionListener's authenticated()

It's important to know if the stream was resumed. authenticated() is the
ideal callback for Managers to reset their state (e.g. cached values of
the connection state). But if the stream was resumed, the cached values
don't have to be reset.
This commit is contained in:
Florian Schmaus 2015-01-07 20:19:04 +01:00
parent 3dd1365a5a
commit e380872a41
10 changed files with 38 additions and 20 deletions

View file

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.caps;
import org.jivesoftware.smack.AbstractConnectionClosedListener;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
@ -274,7 +274,7 @@ public class EntityCapsManager extends Manager {
this.sdm = ServiceDiscoveryManager.getInstanceFor(connection);
instances.put(connection, this);
connection.addConnectionListener(new AbstractConnectionClosedListener() {
connection.addConnectionListener(new AbstractConnectionListener() {
@Override
public void connected(XMPPConnection connection) {
// It's not clear when a server would report the caps stream
@ -283,17 +283,17 @@ public class EntityCapsManager extends Manager {
processCapsStreamFeatureIfAvailable(connection);
}
@Override
public void authenticated(XMPPConnection connection) {
public void authenticated(XMPPConnection connection, boolean resumed) {
// It's not clear when a server would report the caps stream
// feature, so we try to process it after we are connected and
// once after we are authenticated.
processCapsStreamFeatureIfAvailable(connection);
}
@Override
public void connectionTerminated() {
presenceSend = false;
}
// Reset presenceSend when the connection was not resumed
if (!resumed) {
presenceSend = false;
}
}
private void processCapsStreamFeatureIfAvailable(XMPPConnection connection) {
CapsExtension capsExtension = connection.getFeature(
CapsExtension.ELEMENT, CapsExtension.NAMESPACE);

View file

@ -137,7 +137,7 @@ public class PingManager extends Manager {
}, PING_PACKET_FILTER);
connection.addConnectionListener(new AbstractConnectionClosedListener() {
@Override
public void authenticated(XMPPConnection connection) {
public void authenticated(XMPPConnection connection, boolean resumed) {
maybeSchedulePingServerTask();
}
@Override

View file

@ -186,7 +186,11 @@ public class PrivacyListManager extends Manager {
}, PRIVACY_RESULT);
connection.addConnectionListener(new AbstractConnectionListener() {
@Override
public void reconnectionSuccessful() {
public void authenticated(XMPPConnection connection, boolean resumed) {
// No need to reset the cache if the connection got resumed.
if (resumed) {
return;
}
cachedActiveListName = cachedDefaultListName = null;
}
});