mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 10:49:41 +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:
parent
3dd1365a5a
commit
e380872a41
10 changed files with 38 additions and 20 deletions
|
@ -31,7 +31,7 @@ public class AbstractConnectionListener implements ConnectionListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void authenticated(XMPPConnection connection) {
|
||||
public void authenticated(XMPPConnection connection, boolean resumed) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
|
|
@ -500,7 +500,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
if (config.isDebuggerEnabled() && debugger != null) {
|
||||
debugger.userHasLogged(user);
|
||||
}
|
||||
callConnectionAuthenticatedListener();
|
||||
callConnectionAuthenticatedListener(resumed);
|
||||
|
||||
// Set presence to online. It is important that this is done after
|
||||
// callConnectionAuthenticatedListener(), as this call will also
|
||||
|
@ -1040,9 +1040,15 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
}
|
||||
|
||||
protected void callConnectionAuthenticatedListener() {
|
||||
protected void callConnectionAuthenticatedListener(boolean resumed) {
|
||||
for (ConnectionListener listener : getConnectionListeners()) {
|
||||
listener.authenticated(this);
|
||||
try {
|
||||
listener.authenticated(this, resumed);
|
||||
} catch (Exception e) {
|
||||
// Catch and print any exception so we can recover
|
||||
// from a faulty listener and finish the shutdown process
|
||||
LOGGER.log(Level.SEVERE, "Exception in authenticated listener", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public interface ConnectionListener {
|
|||
* TODO
|
||||
* @param connection
|
||||
*/
|
||||
public void authenticated(XMPPConnection connection);
|
||||
public void authenticated(XMPPConnection connection, boolean resumed);
|
||||
|
||||
/**
|
||||
* Notification that the connection was closed normally or that the reconnection
|
||||
|
|
|
@ -264,7 +264,7 @@ public class ReconnectionManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void authenticated(XMPPConnection connection) {
|
||||
public void authenticated(XMPPConnection connection, boolean resumed) {
|
||||
done = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ public class Roster {
|
|||
connection.addConnectionListener(new AbstractConnectionClosedListener() {
|
||||
|
||||
@Override
|
||||
public void authenticated(XMPPConnection connection) {
|
||||
public void authenticated(XMPPConnection connection, boolean resumed) {
|
||||
// Anonymous users can't have a roster, but it is possible that a Roster instance is
|
||||
// retrieved if getRoster() is called *before* connect(). So we have to check here
|
||||
// again if it's an anonymous connection.
|
||||
|
@ -146,6 +146,10 @@ public class Roster {
|
|||
return;
|
||||
if (!connection.isRosterLoadedAtLogin())
|
||||
return;
|
||||
// We are done here if the connection was resumed
|
||||
if (resumed) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Roster.this.reload();
|
||||
}
|
||||
|
|
|
@ -80,8 +80,12 @@ public abstract class AbstractDebugger implements SmackDebugger {
|
|||
log("XMPPConnection connected ("
|
||||
+ connection.getConnectionCounter() + ")");
|
||||
}
|
||||
public void authenticated(XMPPConnection connection) {
|
||||
log("XMPPConnection authenticated (" + connection.getConnectionCounter() + ")");
|
||||
public void authenticated(XMPPConnection connection, boolean resumed) {
|
||||
String logString = "XMPPConnection authenticated (" + connection.getConnectionCounter() + ")";
|
||||
if (resumed) {
|
||||
logString += " and resumed";
|
||||
}
|
||||
log(logString);
|
||||
}
|
||||
public void connectionClosed() {
|
||||
log(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue