From 5bb236def03cd55945d042052969e7398d482b79 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Wed, 14 Sep 2011 00:45:47 +0400 Subject: [PATCH] Added -Ddebug.mage parameter for Mage.Client to disable timeout for debugging (got disconnected while debugging server code in IDEA). --- Mage.Common/src/mage/remote/Session.java | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Mage.Common/src/mage/remote/Session.java b/Mage.Common/src/mage/remote/Session.java index 0b4251a9090..987fc3e46fc 100644 --- a/Mage.Common/src/mage/remote/Session.java +++ b/Mage.Common/src/mage/remote/Session.java @@ -77,14 +77,11 @@ public class Session { private SessionState sessionState = SessionState.DISCONNECTED; private Connection connection; - /** - * For locking session object. - * Read-write locking is used for better performance, as in most cases session object won't be changed so - * there shouldn't be any penalty for synchronization. - * - * @author nantuko - */ -// private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); + private static boolean debugMode = false; + + static { + debugMode = System.getProperty("debug.mage") != null; + } public Session(MageClient client) { this.client = client; @@ -135,8 +132,14 @@ public class Session { callbackClient = new Client(clientLocator, "callback", clientMetadata); Map listenerMetadata = new HashMap(); - listenerMetadata.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "10000"); - listenerMetadata.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, "9000"); + if (debugMode) { + // prevent client from disconnecting while debugging + listenerMetadata.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "1000000"); + listenerMetadata.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, "900000"); + } else { + listenerMetadata.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "10000"); + listenerMetadata.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, "9000"); + } callbackClient.connect(new ClientConnectionListener(), listenerMetadata); Map callbackMetadata = new HashMap();