1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-02 03:18:09 -09:00

Added -Ddebug.mage parameter for Mage.Client to disable timeout for debugging (got disconnected while debugging server code in IDEA).

This commit is contained in:
magenoxx 2011-09-14 00:45:47 +04:00
parent 5ad77e8a88
commit 5bb236def0

View file

@ -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<String, String> listenerMetadata = new HashMap<String, String>();
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<String, String> callbackMetadata = new HashMap<String, String>();