Some minor user handling changes.

This commit is contained in:
LevelX2 2017-09-02 00:46:24 +02:00
parent f80129a0ed
commit 720351c065
3 changed files with 8 additions and 10 deletions

View file

@ -374,11 +374,9 @@ public class Session {
call.setMessageId(messageId++);
callbackHandler.handleCallbackOneway(new Callback(call));
} catch (HandleCallbackException ex) {
// ex.printStackTrace();
UserManager.instance.getUser(userId).ifPresent(user -> {
logger.warn("SESSION CALLBACK EXCEPTION - " + user.getName() + " userId " + userId);
logger.warn(" - method: " + call.getMethod());
logger.warn(" - cause: " + getBasicCause(ex).toString());
user.setUserState(User.UserState.Disconnected);
logger.warn("SESSION CALLBACK EXCEPTION - " + user.getName() + " userId " + userId + " - cause: " + getBasicCause(ex).toString());
logger.trace("Stack trace:", ex);
SessionManager.instance.disconnect(sessionId, LostConnection);
});

View file

@ -159,15 +159,15 @@ public class User {
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
if (sessionId.isEmpty()) {
userState = UserState.Disconnected;
setUserState(UserState.Disconnected);
lostConnection();
logger.trace("USER - lost connection: " + userName + " id: " + userId);
} else if (userState == UserState.Created) {
userState = UserState.Connected;
setUserState(UserState.Connected);
logger.trace("USER - created: " + userName + " id: " + userId);
} else {
userState = UserState.Connected;
setUserState(UserState.Connected);
reconnect();
logger.trace("USER - reconnected: " + userName + " id: " + userId);
}
@ -339,7 +339,7 @@ public class User {
}
lastActivity = new Date();
if (userState == UserState.Disconnected) { // this can happen if user reconnects very fast after disconnect
userState = UserState.Connected;
setUserState(UserState.Connected);
}
}