mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
SPARK-1750: Restore presence after reconnect (#191)
When Spark reconnects successfully, the previous presence state of the local user should be restored.
This commit is contained in:
@ -57,6 +57,9 @@ public final class SessionManager implements ConnectionListener {
|
|||||||
private String userBareAddress;
|
private String userBareAddress;
|
||||||
private DiscoverItems discoverItems;
|
private DiscoverItems discoverItems;
|
||||||
|
|
||||||
|
// Stores our presence state at the time that the last connectionClosedOnError happened.
|
||||||
|
private Presence preError;
|
||||||
|
|
||||||
public SessionManager() {
|
public SessionManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +147,7 @@ public final class SessionManager implements ConnectionListener {
|
|||||||
*/
|
*/
|
||||||
public void connectionClosedOnError(final Exception ex) {
|
public void connectionClosedOnError(final Exception ex) {
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
|
preError = Workspace.getInstance().getStatusBar().getPresence();
|
||||||
final Presence presence = new Presence(Presence.Type.unavailable);
|
final Presence presence = new Presence(Presence.Type.unavailable);
|
||||||
changePresence(presence);
|
changePresence(presence);
|
||||||
|
|
||||||
@ -276,7 +280,17 @@ public final class SessionManager implements ConnectionListener {
|
|||||||
public void reconnectingIn(int i) {
|
public void reconnectingIn(int i) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reconnectionSuccessful() {
|
public void reconnectionSuccessful()
|
||||||
|
{
|
||||||
|
// Restore the presence state that we were in just before the disconnection happened.
|
||||||
|
if ( preError != null )
|
||||||
|
{
|
||||||
|
SwingUtilities.invokeLater( () ->
|
||||||
|
{
|
||||||
|
changePresence( preError );
|
||||||
|
preError = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reconnectionFailed(Exception exception) {
|
public void reconnectionFailed(Exception exception) {
|
||||||
|
|||||||
Reference in New Issue
Block a user