diff --git a/Mage.Client/serverlist.txt b/Mage.Client/serverlist.txt index e8fdb00bb9..6b5f46a2e8 100644 --- a/Mage.Client/serverlist.txt +++ b/Mage.Client/serverlist.txt @@ -1,5 +1,5 @@ woogerworks (Version 1.3.0 dev 2014-10-29V2) :xmage.woogerworks.com:17171 XMage.info 1 (Version 1.3.0 dev 2014-11-29v2) :176.31.186.181:17171 -XMage.info 2 (Version 1.3.0 dev 2014-11-29V1) :176.31.186.181:17000 +XMage.info 2 (Version 1.3.0 dev 2014-11-29V2) :176.31.186.181:17000 Seedds Server (Version 1.3.0 dev 2014-11-29v1) :115.29.203.80:17171 localhost -> connect to your local server (must be started):localhost:17171 diff --git a/Mage.Server/src/main/java/mage/server/Session.java b/Mage.Server/src/main/java/mage/server/Session.java index e8ee3888ad..2a4cee3dae 100644 --- a/Mage.Server/src/main/java/mage/server/Session.java +++ b/Mage.Server/src/main/java/mage/server/Session.java @@ -218,23 +218,24 @@ public class Session { public void userLostConnection() { boolean lockSet = false; try { - if(lock.tryLock(500, TimeUnit.MILLISECONDS)) { + if(lock.tryLock(5000, TimeUnit.MILLISECONDS)) { lockSet = true; - logger.trace("SESSION LOCK SET sessionId: " + sessionId); - User user = UserManager.getInstance().getUser(userId); - if (user == null || !user.isConnected()) { - return; //user was already disconnected by other thread - } - if (!user.getSessionId().equals(sessionId)) { - // user already reconnected with another instance - logger.info("OLD SESSION IGNORED - " + user.getName()); - return; - } - // logger.info("LOST CONNECTION - " + user.getName() + " id: " + userId); - UserManager.getInstance().disconnect(userId, DisconnectReason.LostConnection); + logger.debug("SESSION LOCK SET sessionId: " + sessionId); } else { logger.error("CAN'T GET LOCK - userId: " + userId); } + User user = UserManager.getInstance().getUser(userId); + if (user == null || !user.isConnected()) { + return; //user was already disconnected by other thread + } + if (!user.getSessionId().equals(sessionId)) { + // user already reconnected with another instance + logger.info("OLD SESSION IGNORED - " + user.getName()); + return; + } + // logger.info("LOST CONNECTION - " + user.getName() + " id: " + userId); + UserManager.getInstance().disconnect(userId, DisconnectReason.LostConnection); + } catch (InterruptedException ex) { logger.error("SESSION LOCK lost connection - userId: " + userId, ex); } @@ -250,13 +251,13 @@ public class Session { public void kill(DisconnectReason reason) { boolean lockSet = false; try { - if(lock.tryLock(500, TimeUnit.MILLISECONDS)) { + if(lock.tryLock(5000, TimeUnit.MILLISECONDS)) { lockSet = true; - logger.debug("SESSION LOCK SET sessionId: " + sessionId); - UserManager.getInstance().removeUser(userId, reason); + logger.debug("SESSION LOCK SET sessionId: " + sessionId); } else { logger.error("SESSION LOCK - kill: userId " + userId); } + UserManager.getInstance().removeUser(userId, reason); } catch (InterruptedException ex) { logger.error("SESSION LOCK - kill: userId " + userId, ex); } @@ -272,8 +273,8 @@ public class Session { public void fireCallback(final ClientCallback call) { try { - call.setMessageId(messageId++); - callbackHandler.handleCallbackOneway(new Callback(call)); + call.setMessageId(messageId++); + callbackHandler.handleCallbackOneway(new Callback(call)); } catch (HandleCallbackException ex) { User user = UserManager.getInstance().getUser(userId); logger.warn("SESSION CALLBACK EXCEPTION - " + (user != null ? user.getName():"") + " userId " + userId); diff --git a/Mage.Server/src/main/java/mage/server/TableManager.java b/Mage.Server/src/main/java/mage/server/TableManager.java index bd114b5420..1ef11e9f7c 100644 --- a/Mage.Server/src/main/java/mage/server/TableManager.java +++ b/Mage.Server/src/main/java/mage/server/TableManager.java @@ -363,7 +363,19 @@ public class TableManager { Collection users = UserManager.getInstance().getUsers(); logger.debug("--------User: " + users.size() + " [userId | since | lock | name -----------------------"); for (User user :users) { - logger.debug(user.getId() + " | " + formatter.format(user.getConnectionTime()) + " | " + (SessionManager.getInstance().getSession(user.getSessionId()).isLocked()?"L":"-") + " | " + user.getName() +" (" +user.getUserState().toString() + " - " + user.getPingInfo() + ")"); + Session session = SessionManager.getInstance().getSession(user.getSessionId()); + String sessionState = "N"; + if (session != null) { + if (session.isLocked()) { + sessionState = "L"; + } else { + sessionState = "+"; + } + } + logger.debug(user.getId() + + " | " + formatter.format(user.getConnectionTime()) + + " | " + sessionState + + " | " + user.getName() +" (" +user.getUserState().toString() + " - " + user.getPingInfo() + ")"); } ArrayList chatSessions = ChatManager.getInstance().getChatSessions(); logger.debug("------- ChatSessions: " + chatSessions.size() + " ----------------------------------");