forked from External/mage
Some changes to user / session / chat / tournament handling (not all tested yet).
This commit is contained in:
parent
e8cfb2231c
commit
d3a2ba683c
13 changed files with 105 additions and 86 deletions
|
|
@ -111,32 +111,37 @@ public class SessionManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
public synchronized void disconnect(String sessionId, DisconnectReason reason) {
|
||||
Session session = sessions.get(sessionId);
|
||||
public void disconnect(String sessionId, DisconnectReason reason) {
|
||||
Session session = sessions.get(sessionId);
|
||||
if (session != null) {
|
||||
sessions.remove(sessionId);
|
||||
switch (reason) {
|
||||
case Disconnected:
|
||||
session.kill(reason);
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_KILLED, sessionId);
|
||||
break;
|
||||
case SessionExpired:
|
||||
session.kill(reason);
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_EXPIRED, sessionId);
|
||||
break;
|
||||
case AdminDisconnect:
|
||||
session.kill(reason);
|
||||
break;
|
||||
case LostConnection:
|
||||
session.userLostConnection();
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED, sessionId);
|
||||
break;
|
||||
default:
|
||||
logger.error("endSession: unexpected reason " + reason.toString() + " - sessionId: "+ sessionId);
|
||||
synchronized (session) {
|
||||
if (!sessions.containsKey(sessionId)) {
|
||||
// session was removed meanwhile by another thread so we can return
|
||||
return;
|
||||
}
|
||||
sessions.remove(sessionId);
|
||||
switch (reason) {
|
||||
case Disconnected:
|
||||
session.kill(reason);
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_KILLED, sessionId);
|
||||
break;
|
||||
case SessionExpired:
|
||||
session.kill(reason);
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_EXPIRED, sessionId);
|
||||
break;
|
||||
case AdminDisconnect:
|
||||
session.kill(reason);
|
||||
break;
|
||||
case LostConnection:
|
||||
session.userLostConnection();
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED, sessionId);
|
||||
break;
|
||||
default:
|
||||
logger.error("endSession: unexpected reason " + reason.toString() + " - sessionId: "+ sessionId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.error("endSession: could not find session with id " + sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Map<String, Session> getSessions() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue