Changed user disconnect handling. The user in the server is no longer deleted directly after connection problem, disconnect or quit. The user object remains now for 8 minutes so the rejoin not possible after disconnect problem should be solved (I hope so). We will see. Also fixed the problem, that the table panel was not shown, if a player disconected and reconected.

This commit is contained in:
LevelX2 2017-08-13 16:22:18 +02:00
parent 5dbb89772e
commit bae7f154df
10 changed files with 220 additions and 170 deletions

View file

@ -125,34 +125,30 @@ public enum SessionManager {
public void disconnect(String sessionId, DisconnectReason reason) {
Session session = sessions.get(sessionId);
if (session != null) {
if (reason != DisconnectReason.AdminDisconnect) {
if (!sessions.containsKey(sessionId)) {
// session was removed meanwhile by another thread so we can return
return;
}
logger.debug("DISCONNECT " + reason.toString() + " - sessionId: " + sessionId);
sessions.remove(sessionId);
switch (reason) {
case Disconnected: // regular session end or wrong client version
if (session.getUserId() != null) { // if wrong client version no userId is set
session.kill(reason);
}
break;
case SessionExpired: // session ends after no reconnect happens in the defined time span
session.kill(reason);
break;
case LostConnection: // user lost connection - session expires countdaoun starts
session.userLostConnection();
break;
case ConnectingOtherInstance:
break;
default:
logger.trace("endSession: unexpected reason " + reason.toString() + " - sessionId: " + sessionId);
}
} else {
sessions.remove(sessionId);
session.kill(reason);
if (!sessions.containsKey(sessionId)) {
// session was removed meanwhile by another thread so we can return
return;
}
logger.debug("DISCONNECT " + reason.toString() + " - sessionId: " + sessionId);
sessions.remove(sessionId);
switch (reason) {
case AdminDisconnect:
session.kill(reason);
break;
case ConnectingOtherInstance:
case Disconnected: // regular session end or wrong client version
UserManager.instance.disconnect(session.getUserId(), reason);
break;
case SessionExpired: // session ends after no reconnect happens in the defined time span
break;
case LostConnection: // user lost connection - session expires countdown starts
session.userLostConnection();
UserManager.instance.disconnect(session.getUserId(), reason);
break;
default:
logger.trace("endSession: unexpected reason " + reason.toString() + " - sessionId: " + sessionId);
}
}
}