diff --git a/Mage.Common/src/mage/remote/SessionImpl.java b/Mage.Common/src/mage/remote/SessionImpl.java index 8b4b6c487a..23f5f1b858 100644 --- a/Mage.Common/src/mage/remote/SessionImpl.java +++ b/Mage.Common/src/mage/remote/SessionImpl.java @@ -205,8 +205,8 @@ public class SessionImpl implements Session { sessionState = SessionState.CONNECTED; serverState = server.getServerState(); updateDatabase(); - logger.info(new StringBuilder("Connected as ").append(this.getUserName()).append(" to MAGE server at ").append(connection.getHost()).append(":").append(connection.getPort()).toString()); - client.connected(new StringBuilder(this.getUserName()).append("@").append(connection.getHost()).append(":").append(connection.getPort()).append(" ").toString()); + logger.info("Connected as " + this.getUserName() == null ? "":this.getUserName() + " to MAGE server at " + connection.getHost() + ":" + connection.getPort()); + client.connected(this.getUserName() == null ? "":this.getUserName() +"@" + connection.getHost() + ":" + connection.getPort() +" "); return true; } disconnect(false); diff --git a/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.form b/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.form index a711e7a143..eb9b8bb12c 100644 --- a/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.form +++ b/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.form @@ -1,4 +1,4 @@ - +
@@ -6,6 +6,7 @@ + diff --git a/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.java b/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.java index 431a0f3acd..96d13d414f 100644 --- a/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.java +++ b/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.java @@ -411,7 +411,7 @@ public class ConnectDialog extends JDialog { connection.setHost(this.txtServer.getText()); connection.setPort(Integer.valueOf(this.txtPort.getText())); connection.setPassword(new String(txtPassword.getPassword())); - + connection.setUsername("Admin"); connection.setProxyType((ProxyType) this.cbProxyType.getSelectedItem()); if (!this.cbProxyType.getSelectedItem().equals(ProxyType.NONE)) { connection.setProxyHost(this.txtProxyServer.getText()); diff --git a/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.form b/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.form index caae29505a..c03ba93846 100644 --- a/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.form +++ b/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.form @@ -1,4 +1,4 @@ - + @@ -6,6 +6,7 @@ + diff --git a/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java b/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java index ec7eccf69f..df274b1058 100644 --- a/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java +++ b/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java @@ -34,6 +34,9 @@ package mage.server.console; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import mage.interfaces.MageClient; import mage.interfaces.callback.ClientCallback; import mage.remote.Connection; @@ -57,7 +60,8 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { private ConnectDialog connectDialog; private static final Preferences prefs = Preferences.userNodeForPackage(ConsoleFrame.class); private static final MageVersion version = new MageVersion(1, 3, 0, MageVersion.MAGE_VERSION_INFO); - + + private static final ScheduledExecutorService pingTaskExecutor = Executors.newSingleThreadScheduledExecutor(); /** * @return the session */ @@ -84,6 +88,13 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { } catch (Exception ex) { logger.fatal("", ex); } + + pingTaskExecutor.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + session.ping(); + } + }, 60, 60, TimeUnit.SECONDS); } public boolean connect(Connection connection) { diff --git a/Mage.Server/src/main/java/mage/server/Session.java b/Mage.Server/src/main/java/mage/server/Session.java index 9c057fd772..891869173f 100644 --- a/Mage.Server/src/main/java/mage/server/Session.java +++ b/Mage.Server/src/main/java/mage/server/Session.java @@ -125,6 +125,9 @@ public class Session { user = UserManager.getInstance().findUser("Admin"); } user.setUserData(new UserData(UserGroup.ADMIN, 0, false)); + if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) { + logger.info("Error connecting Admin!"); + } this.userId = user.getId(); }