* Some more changes to user disconnect handling.

This commit is contained in:
LevelX2 2017-08-16 07:51:48 +02:00
parent a3dd6f6956
commit 8ab9abb8e8
3 changed files with 10 additions and 5 deletions

View file

@ -1440,7 +1440,7 @@ public class SessionImpl implements Session {
@Override
public boolean endUserSession(String userSessionId) {
try {
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to mute userSessionId " + userSessionId + '?', "WARNING",
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to end userSessionId " + userSessionId + '?', "WARNING",
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
if (isConnected()) {
server.endUserSession(sessionId, userSessionId);

View file

@ -4,9 +4,9 @@ package mage.server;
*
* @author LevelX2
*/
public enum DisconnectReason {
LostConnection(" has lost connection"),
BecameInactive(" has become inactive"),
Disconnected(" has left XMage"),
CleaningUp(" [cleaning up]"),
ConnectingOtherInstance(" reconnected and replaced still active old session"),
@ -15,11 +15,12 @@ public enum DisconnectReason {
Undefined("");
String message;
DisconnectReason(String message){
DisconnectReason(String message) {
this.message = message;
}
public String getMessage(){
public String getMessage() {
return message;
}
}

View file

@ -174,8 +174,12 @@ public enum UserManager {
calendarRemove.add(Calendar.MINUTE, -8);
List<User> toRemove = new ArrayList<>();
for (User user : users.values()) {
if (user.getUserState() == UserState.Disconnected || user.getUserState() == UserState.Offline
if (user.getUserState() != UserState.Offline
&& user.isExpired(calendarExp.getTime())) {
if (user.getUserState() == UserState.Connected) {
user.lostConnection();
disconnect(user.getId(), DisconnectReason.BecameInactive);
}
user.setUserState(UserState.Offline);
}
if (user.getUserState() == UserState.Offline && user.isExpired(calendarRemove.getTime())) {