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++); call.setMessageId(messageId++);
callbackHandler.handleCallbackOneway(new Callback(call)); callbackHandler.handleCallbackOneway(new Callback(call));
} catch (HandleCallbackException ex) { } catch (HandleCallbackException ex) {
// ex.printStackTrace();
UserManager.instance.getUser(userId).ifPresent(user -> { UserManager.instance.getUser(userId).ifPresent(user -> {
logger.warn("SESSION CALLBACK EXCEPTION - " + user.getName() + " userId " + userId); user.setUserState(User.UserState.Disconnected);
logger.warn(" - method: " + call.getMethod()); logger.warn("SESSION CALLBACK EXCEPTION - " + user.getName() + " userId " + userId + " - cause: " + getBasicCause(ex).toString());
logger.warn(" - cause: " + getBasicCause(ex).toString());
logger.trace("Stack trace:", ex); logger.trace("Stack trace:", ex);
SessionManager.instance.disconnect(sessionId, LostConnection); SessionManager.instance.disconnect(sessionId, LostConnection);
}); });

View file

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

View file

@ -81,9 +81,9 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
if (game.getPlayerList().contains(sourceId)) { if (game.getPlayerList().contains(sourceId)) {
this.zoneChangeCounter = 0; this.zoneChangeCounter = 0;
} else { } else {
logger.error("The provided sourceId is not connected to an object in the game id:" + sourceId); logger.error("The provided sourceId is not connected to an object in the game id: " + sourceId);
for (StackObject stackObject : game.getStack()) { for (StackObject stackObject : game.getStack()) {
logger.error("StackObject: " + stackObject.getId() + " sourceId" + stackObject.getSourceId() + " name" + stackObject.getName()); logger.error("StackObject: " + stackObject.getId() + " sourceId " + stackObject.getSourceId() + " name " + stackObject.getName());
} }
mageObject = game.getLastKnownInformation(sourceId, Zone.STACK); mageObject = game.getLastKnownInformation(sourceId, Zone.STACK);
if (mageObject != null) { if (mageObject != null) {