Server console - Some updates to Admin handling.

This commit is contained in:
LevelX2 2014-08-18 17:56:21 +02:00
parent 43e82b7a1a
commit a6332e6505
6 changed files with 22 additions and 6 deletions

View file

@ -205,8 +205,8 @@ public class SessionImpl implements Session {
sessionState = SessionState.CONNECTED; sessionState = SessionState.CONNECTED;
serverState = server.getServerState(); serverState = server.getServerState();
updateDatabase(); updateDatabase();
logger.info(new StringBuilder("Connected as ").append(this.getUserName()).append(" to MAGE server at ").append(connection.getHost()).append(":").append(connection.getPort()).toString()); logger.info("Connected as " + this.getUserName() == null ? "":this.getUserName() + " to MAGE server at " + connection.getHost() + ":" + connection.getPort());
client.connected(new StringBuilder(this.getUserName()).append("@").append(connection.getHost()).append(":").append(connection.getPort()).append(" ").toString()); client.connected(this.getUserName() == null ? "":this.getUserName() +"@" + connection.getHost() + ":" + connection.getPort() +" ");
return true; return true;
} }
disconnect(false); disconnect(false);

View file

@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties> <Properties>
@ -6,6 +6,7 @@
</Properties> </Properties>
<SyntheticProperties> <SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties> </SyntheticProperties>
<AuxValues> <AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>

View file

@ -411,7 +411,7 @@ public class ConnectDialog extends JDialog {
connection.setHost(this.txtServer.getText()); connection.setHost(this.txtServer.getText());
connection.setPort(Integer.valueOf(this.txtPort.getText())); connection.setPort(Integer.valueOf(this.txtPort.getText()));
connection.setPassword(new String(txtPassword.getPassword())); connection.setPassword(new String(txtPassword.getPassword()));
connection.setUsername("Admin");
connection.setProxyType((ProxyType) this.cbProxyType.getSelectedItem()); connection.setProxyType((ProxyType) this.cbProxyType.getSelectedItem());
if (!this.cbProxyType.getSelectedItem().equals(ProxyType.NONE)) { if (!this.cbProxyType.getSelectedItem().equals(ProxyType.NONE)) {
connection.setProxyHost(this.txtProxyServer.getText()); connection.setProxyHost(this.txtProxyServer.getText());

View file

@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties> <Properties>
@ -6,6 +6,7 @@
</Properties> </Properties>
<SyntheticProperties> <SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties> </SyntheticProperties>
<AuxValues> <AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>

View file

@ -34,6 +34,9 @@
package mage.server.console; 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.MageClient;
import mage.interfaces.callback.ClientCallback; import mage.interfaces.callback.ClientCallback;
import mage.remote.Connection; import mage.remote.Connection;
@ -58,6 +61,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
private static final Preferences prefs = Preferences.userNodeForPackage(ConsoleFrame.class); 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 MageVersion version = new MageVersion(1, 3, 0, MageVersion.MAGE_VERSION_INFO);
private static final ScheduledExecutorService pingTaskExecutor = Executors.newSingleThreadScheduledExecutor();
/** /**
* @return the session * @return the session
*/ */
@ -84,6 +88,13 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
} catch (Exception ex) { } catch (Exception ex) {
logger.fatal("", ex); logger.fatal("", ex);
} }
pingTaskExecutor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
session.ping();
}
}, 60, 60, TimeUnit.SECONDS);
} }
public boolean connect(Connection connection) { public boolean connect(Connection connection) {

View file

@ -125,6 +125,9 @@ public class Session {
user = UserManager.getInstance().findUser("Admin"); user = UserManager.getInstance().findUser("Admin");
} }
user.setUserData(new UserData(UserGroup.ADMIN, 0, false)); user.setUserData(new UserData(UserGroup.ADMIN, 0, false));
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
logger.info("Error connecting Admin!");
}
this.userId = user.getId(); this.userId = user.getId();
} }