mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
[AdminConsole] Added the possibility to end user session without kicking him/her off. Fixed bug with discarding row selection in user table
This commit is contained in:
parent
44ee670baf
commit
74ddaa4a57
8 changed files with 159 additions and 99 deletions
|
@ -146,6 +146,7 @@ public interface MageServer {
|
||||||
//admin methods
|
//admin methods
|
||||||
List<UserView> getUsers(String sessionId) throws MageException;
|
List<UserView> getUsers(String sessionId) throws MageException;
|
||||||
void disconnectUser(String sessionId, String userSessionId) throws MageException;
|
void disconnectUser(String sessionId, String userSessionId) throws MageException;
|
||||||
|
void endUserSession(String sessionId, String userSessionId) throws MageException;
|
||||||
void removeTable(String sessionId, UUID tableId) throws MageException;
|
void removeTable(String sessionId, UUID tableId) throws MageException;
|
||||||
void sendBroadcastMessage(String sessionId, String message) throws MageException;
|
void sendBroadcastMessage(String sessionId, String message) throws MageException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,18 +28,6 @@
|
||||||
|
|
||||||
package mage.remote;
|
package mage.remote;
|
||||||
|
|
||||||
import java.net.Authenticator;
|
|
||||||
import java.net.ConnectException;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.PasswordAuthentication;
|
|
||||||
import java.net.SocketException;
|
|
||||||
import java.net.SocketTimeoutException;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.cards.decks.InvalidDeckException;
|
import mage.cards.decks.InvalidDeckException;
|
||||||
|
@ -56,22 +44,9 @@ import mage.interfaces.MageServer;
|
||||||
import mage.interfaces.ServerState;
|
import mage.interfaces.ServerState;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.utils.CompressUtil;
|
import mage.utils.CompressUtil;
|
||||||
import mage.view.DraftPickView;
|
import mage.view.*;
|
||||||
import mage.view.GameTypeView;
|
|
||||||
import mage.view.MatchView;
|
|
||||||
import mage.view.TableView;
|
|
||||||
import mage.view.TournamentTypeView;
|
|
||||||
import mage.view.TournamentView;
|
|
||||||
import mage.view.UserDataView;
|
|
||||||
import mage.view.UserView;
|
|
||||||
import mage.view.UsersView;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jboss.remoting.CannotConnectException;
|
import org.jboss.remoting.*;
|
||||||
import org.jboss.remoting.Client;
|
|
||||||
import org.jboss.remoting.ConnectionListener;
|
|
||||||
import org.jboss.remoting.ConnectionValidator;
|
|
||||||
import org.jboss.remoting.InvokerLocator;
|
|
||||||
import org.jboss.remoting.Remoting;
|
|
||||||
import org.jboss.remoting.callback.Callback;
|
import org.jboss.remoting.callback.Callback;
|
||||||
import org.jboss.remoting.callback.HandleCallbackException;
|
import org.jboss.remoting.callback.HandleCallbackException;
|
||||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||||
|
@ -79,6 +54,9 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
|
||||||
import org.jboss.remoting.transport.socket.SocketWrapper;
|
import org.jboss.remoting.transport.socket.SocketWrapper;
|
||||||
import org.jboss.remoting.transporter.TransporterClient;
|
import org.jboss.remoting.transporter.TransporterClient;
|
||||||
|
|
||||||
|
import java.net.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -1244,6 +1222,21 @@ public class SessionImpl implements Session {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean endUserSession(String userSessionId) {
|
||||||
|
try {
|
||||||
|
if (isConnected()) {
|
||||||
|
server.endUserSession(sessionId, userSessionId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (MageException ex) {
|
||||||
|
handleMageException(ex);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
handleThrowable(t);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void handleThrowable(Throwable t) {
|
private void handleThrowable(Throwable t) {
|
||||||
logger.fatal("Communication error", t);
|
logger.fatal("Communication error", t);
|
||||||
sessionState = SessionState.SERVER_UNAVAILABLE;
|
sessionState = SessionState.SERVER_UNAVAILABLE;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.remote.interfaces;
|
package mage.remote.interfaces;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.remote.Connection;
|
import mage.remote.Connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,5 +48,7 @@ public interface Connect {
|
||||||
|
|
||||||
boolean disconnectUser(String userSessionId);
|
boolean disconnectUser(String userSessionId);
|
||||||
|
|
||||||
|
boolean endUserSession(String userSessionId);
|
||||||
|
|
||||||
String getSessionId();
|
String getSessionId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.1" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jSplitPane1" alignment="1" pref="395" max="32767" attributes="0"/>
|
<Component id="jSplitPane1" alignment="1" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jScrollPane1" alignment="0" pref="360" max="32767" attributes="0"/>
|
<Component id="jScrollPane1" alignment="0" pref="358" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -101,16 +101,21 @@
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="btnDisconnect" min="-2" max="-2" attributes="0"/>
|
<Component id="btnDisconnect" min="-2" pref="103" max="-2" attributes="0"/>
|
||||||
<EmptySpace pref="164" max="32767" attributes="0"/>
|
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||||
|
<Component id="btnEndSession" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace pref="8" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<Component id="btnDisconnect" min="-2" max="-2" attributes="0"/>
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<EmptySpace pref="10" max="32767" attributes="0"/>
|
<Component id="btnDisconnect" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="btnEndSession" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
|
@ -124,6 +129,14 @@
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDisconnectActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDisconnectActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="btnEndSession">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="End session"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnEndSessionActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
|
@ -139,7 +152,7 @@
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jPanel5" alignment="0" max="32767" attributes="0"/>
|
<Component id="jPanel5" alignment="0" max="32767" attributes="0"/>
|
||||||
<Component id="jPanel6" alignment="0" max="32767" attributes="0"/>
|
<Component id="jPanel6" alignment="0" pref="301" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
|
@ -163,7 +176,7 @@
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jScrollPane2" alignment="0" pref="359" max="32767" attributes="0"/>
|
<Component id="jScrollPane2" alignment="0" pref="356" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -192,27 +205,27 @@
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="btnDelete" min="-2" max="-2" attributes="0"/>
|
<Component id="btnRemoveTable" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace pref="235" max="32767" attributes="0"/>
|
<EmptySpace pref="170" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<Component id="btnDelete" min="-2" max="-2" attributes="0"/>
|
<Component id="btnRemoveTable" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="32767" attributes="0"/>
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Component class="javax.swing.JButton" name="btnDelete">
|
<Component class="javax.swing.JButton" name="btnRemoveTable">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="Remove"/>
|
<Property name="label" type="java.lang.String" value="Remove Table"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDeleteActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnRemoveTableActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
|
|
|
@ -33,18 +33,18 @@
|
||||||
*/
|
*/
|
||||||
package mage.server.console;
|
package mage.server.console;
|
||||||
|
|
||||||
|
import mage.remote.Session;
|
||||||
|
import mage.view.TableView;
|
||||||
|
import mage.view.UserView;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.AbstractTableModel;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import javax.swing.SwingWorker;
|
|
||||||
import javax.swing.table.AbstractTableModel;
|
|
||||||
|
|
||||||
import mage.remote.Session;
|
|
||||||
import mage.view.TableView;
|
|
||||||
import mage.view.UserView;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -113,12 +113,13 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
tblUsers = new javax.swing.JTable();
|
tblUsers = new javax.swing.JTable();
|
||||||
jPanel4 = new javax.swing.JPanel();
|
jPanel4 = new javax.swing.JPanel();
|
||||||
btnDisconnect = new javax.swing.JButton();
|
btnDisconnect = new javax.swing.JButton();
|
||||||
|
btnEndSession = new javax.swing.JButton();
|
||||||
jPanel2 = new javax.swing.JPanel();
|
jPanel2 = new javax.swing.JPanel();
|
||||||
jPanel5 = new javax.swing.JPanel();
|
jPanel5 = new javax.swing.JPanel();
|
||||||
jScrollPane2 = new javax.swing.JScrollPane();
|
jScrollPane2 = new javax.swing.JScrollPane();
|
||||||
tblTables = new javax.swing.JTable();
|
tblTables = new javax.swing.JTable();
|
||||||
jPanel6 = new javax.swing.JPanel();
|
jPanel6 = new javax.swing.JPanel();
|
||||||
btnDelete = new javax.swing.JButton();
|
btnRemoveTable = new javax.swing.JButton();
|
||||||
|
|
||||||
jSplitPane1.setDividerLocation(250);
|
jSplitPane1.setDividerLocation(250);
|
||||||
jSplitPane1.setResizeWeight(0.5);
|
jSplitPane1.setResizeWeight(0.5);
|
||||||
|
@ -134,7 +135,7 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
);
|
);
|
||||||
jPanel3Layout.setVerticalGroup(
|
jPanel3Layout.setVerticalGroup(
|
||||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
||||||
jPanel4.setVerifyInputWhenFocusTarget(false);
|
jPanel4.setVerifyInputWhenFocusTarget(false);
|
||||||
|
@ -146,19 +147,30 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
btnEndSession.setText("End session");
|
||||||
|
btnEndSession.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnEndSessionActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
|
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
|
||||||
jPanel4.setLayout(jPanel4Layout);
|
jPanel4.setLayout(jPanel4Layout);
|
||||||
jPanel4Layout.setHorizontalGroup(
|
jPanel4Layout.setHorizontalGroup(
|
||||||
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||||
.addComponent(btnDisconnect)
|
.addComponent(btnDisconnect, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addContainerGap(164, Short.MAX_VALUE))
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(btnEndSession)
|
||||||
|
.addContainerGap(8, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
jPanel4Layout.setVerticalGroup(
|
jPanel4Layout.setVerticalGroup(
|
||||||
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||||
|
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(btnDisconnect)
|
.addComponent(btnDisconnect)
|
||||||
.addContainerGap(10, Short.MAX_VALUE))
|
.addComponent(btnEndSession))
|
||||||
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||||
|
@ -189,13 +201,13 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
);
|
);
|
||||||
jPanel5Layout.setVerticalGroup(
|
jPanel5Layout.setVerticalGroup(
|
||||||
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE)
|
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
||||||
btnDelete.setText("Remove");
|
btnRemoveTable.setLabel("Remove Table");
|
||||||
btnDelete.addActionListener(new java.awt.event.ActionListener() {
|
btnRemoveTable.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnDeleteActionPerformed(evt);
|
btnRemoveTableActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -204,13 +216,13 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
jPanel6Layout.setHorizontalGroup(
|
jPanel6Layout.setHorizontalGroup(
|
||||||
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel6Layout.createSequentialGroup()
|
.addGroup(jPanel6Layout.createSequentialGroup()
|
||||||
.addComponent(btnDelete)
|
.addComponent(btnRemoveTable)
|
||||||
.addContainerGap(235, Short.MAX_VALUE))
|
.addContainerGap(170, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
jPanel6Layout.setVerticalGroup(
|
jPanel6Layout.setVerticalGroup(
|
||||||
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel6Layout.createSequentialGroup()
|
.addGroup(jPanel6Layout.createSequentialGroup()
|
||||||
.addComponent(btnDelete)
|
.addComponent(btnRemoveTable)
|
||||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -219,7 +231,7 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
jPanel2Layout.setHorizontalGroup(
|
jPanel2Layout.setHorizontalGroup(
|
||||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
jPanel2Layout.setVerticalGroup(
|
jPanel2Layout.setVerticalGroup(
|
||||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
@ -239,7 +251,7 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE)
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
);
|
);
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
@ -248,14 +260,20 @@ public class ConsolePanel extends javax.swing.JPanel {
|
||||||
ConsoleFrame.getSession().disconnectUser((String)tableUserModel.getValueAt(row, 3));
|
ConsoleFrame.getSession().disconnectUser((String)tableUserModel.getValueAt(row, 3));
|
||||||
}//GEN-LAST:event_btnDisconnectActionPerformed
|
}//GEN-LAST:event_btnDisconnectActionPerformed
|
||||||
|
|
||||||
private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
|
private void btnRemoveTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveTableActionPerformed
|
||||||
int row = this.tblTables.getSelectedRow();
|
int row = this.tblTables.getSelectedRow();
|
||||||
ConsoleFrame.getSession().removeTable((UUID)tableTableModel.getValueAt(row, 7));
|
ConsoleFrame.getSession().removeTable((UUID)tableTableModel.getValueAt(row, 7));
|
||||||
}//GEN-LAST:event_btnDeleteActionPerformed
|
}//GEN-LAST:event_btnRemoveTableActionPerformed
|
||||||
|
|
||||||
|
private void btnEndSessionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEndSessionActionPerformed
|
||||||
|
int row = this.tblUsers.getSelectedRow();
|
||||||
|
ConsoleFrame.getSession().endUserSession((String) tableUserModel.getValueAt(row, 3));
|
||||||
|
}//GEN-LAST:event_btnEndSessionActionPerformed
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton btnDelete;
|
|
||||||
private javax.swing.JButton btnDisconnect;
|
private javax.swing.JButton btnDisconnect;
|
||||||
|
private javax.swing.JButton btnEndSession;
|
||||||
|
private javax.swing.JButton btnRemoveTable;
|
||||||
private javax.swing.JPanel jPanel1;
|
private javax.swing.JPanel jPanel1;
|
||||||
private javax.swing.JPanel jPanel2;
|
private javax.swing.JPanel jPanel2;
|
||||||
private javax.swing.JPanel jPanel3;
|
private javax.swing.JPanel jPanel3;
|
||||||
|
@ -399,6 +417,7 @@ class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
|
||||||
|
|
||||||
private Session session;
|
private Session session;
|
||||||
private ConsolePanel panel;
|
private ConsolePanel panel;
|
||||||
|
private List<UserView> previousUsers;
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(UpdateUsersTask.class);
|
private static final Logger logger = Logger.getLogger(UpdateUsersTask.class);
|
||||||
|
|
||||||
|
@ -410,12 +429,42 @@ class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
this.publish(session.getUsers());
|
List<UserView> users = session.getUsers();
|
||||||
|
if (previousUsers == null || checkUserListChanged(users)) {
|
||||||
|
logger.debug("Need to update the user list");
|
||||||
|
this.publish(users);
|
||||||
|
previousUsers = users;
|
||||||
|
}
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkUserListChanged(List<UserView> usersToCheck) {
|
||||||
|
if (previousUsers == null || usersToCheck == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (previousUsers.size() != usersToCheck.size()) {
|
||||||
|
// new user appeared
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (UserView u1 : previousUsers) {
|
||||||
|
boolean found = false;
|
||||||
|
for (UserView u2 : usersToCheck) {
|
||||||
|
if (u1.getUserName().equals(u2.getUserName())) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
// some new user replaced old one
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// seems nothing has been changed
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void process(List<List<UserView>> view) {
|
protected void process(List<List<UserView>> view) {
|
||||||
panel.update(view.get(0));
|
panel.update(view.get(0));
|
||||||
|
|
|
@ -28,11 +28,6 @@
|
||||||
|
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
|
@ -51,13 +46,7 @@ import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.remote.MageVersionException;
|
import mage.remote.MageVersionException;
|
||||||
import mage.server.draft.CubeFactory;
|
import mage.server.draft.CubeFactory;
|
||||||
import mage.server.draft.DraftManager;
|
import mage.server.draft.DraftManager;
|
||||||
import mage.server.game.DeckValidatorFactory;
|
import mage.server.game.*;
|
||||||
import mage.server.game.GameFactory;
|
|
||||||
import mage.server.game.GameManager;
|
|
||||||
import mage.server.game.GamesRoom;
|
|
||||||
import mage.server.game.GamesRoomManager;
|
|
||||||
import mage.server.game.PlayerFactory;
|
|
||||||
import mage.server.game.ReplayManager;
|
|
||||||
import mage.server.services.LogKeys;
|
import mage.server.services.LogKeys;
|
||||||
import mage.server.services.impl.FeedbackServiceImpl;
|
import mage.server.services.impl.FeedbackServiceImpl;
|
||||||
import mage.server.services.impl.LogServiceImpl;
|
import mage.server.services.impl.LogServiceImpl;
|
||||||
|
@ -66,23 +55,17 @@ import mage.server.tournament.TournamentManager;
|
||||||
import mage.server.util.ConfigSettings;
|
import mage.server.util.ConfigSettings;
|
||||||
import mage.server.util.ServerMessagesUtil;
|
import mage.server.util.ServerMessagesUtil;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
import mage.utils.ActionWithBooleanResult;
|
import mage.utils.*;
|
||||||
import mage.utils.ActionWithNullNegativeResult;
|
import mage.view.*;
|
||||||
import mage.utils.ActionWithTableViewResult;
|
|
||||||
import mage.utils.CompressUtil;
|
|
||||||
import mage.utils.MageVersion;
|
|
||||||
import mage.view.ChatMessage;
|
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
import mage.view.DraftPickView;
|
|
||||||
import mage.view.GameView;
|
|
||||||
import mage.view.MatchView;
|
|
||||||
import mage.view.TableView;
|
|
||||||
import mage.view.TournamentView;
|
|
||||||
import mage.view.UserDataView;
|
|
||||||
import mage.view.UserView;
|
|
||||||
import mage.view.UsersView;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com, noxx
|
* @author BetaSteward_at_googlemail.com, noxx
|
||||||
|
@ -920,6 +903,16 @@ public class MageServerImpl implements MageServer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endUserSession(final String sessionId, final String userSessionId) throws MageException {
|
||||||
|
execute("endUserSession", sessionId, new Action() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
SessionManager.getInstance().endUserSession(sessionId, userSessionId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeTable(final String sessionId, final UUID tableId) throws MageException {
|
public void removeTable(final String sessionId, final UUID tableId) throws MageException {
|
||||||
execute("removeTable", sessionId, new Action() {
|
execute("removeTable", sessionId, new Action() {
|
||||||
|
|
|
@ -27,9 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.server.services.LogKeys;
|
import mage.server.services.LogKeys;
|
||||||
import mage.server.services.impl.LogServiceImpl;
|
import mage.server.services.impl.LogServiceImpl;
|
||||||
|
@ -37,6 +34,10 @@ import mage.view.UserDataView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -134,6 +135,13 @@ public class SessionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void endUserSession(String sessionId, String userSessionId) {
|
||||||
|
if (isAdmin(sessionId)) {
|
||||||
|
disconnect(userSessionId, false);
|
||||||
|
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_END_BY_ADMIN, sessionId, userSessionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAdmin(String sessionId) {
|
public boolean isAdmin(String sessionId) {
|
||||||
Session admin = sessions.get(sessionId);
|
Session admin = sessions.get(sessionId);
|
||||||
if (admin != null) {
|
if (admin != null) {
|
||||||
|
|
|
@ -17,6 +17,8 @@ public interface LogKeys {
|
||||||
|
|
||||||
String KEY_SESSION_DISCONNECTED_BY_ADMIN = "sessionDisconnectedByAdmin";
|
String KEY_SESSION_DISCONNECTED_BY_ADMIN = "sessionDisconnectedByAdmin";
|
||||||
|
|
||||||
|
String KEY_SESSION_END_BY_ADMIN = "sessionEndSessionByAdmin";
|
||||||
|
|
||||||
String KEY_NOT_VALID_SESSION = "sessionNotValid";
|
String KEY_NOT_VALID_SESSION = "sessionNotValid";
|
||||||
|
|
||||||
String KEY_NOT_VALID_SESSION_INTERNAL = "sessionNotValidInternal";
|
String KEY_NOT_VALID_SESSION_INTERNAL = "sessionNotValidInternal";
|
||||||
|
|
Loading…
Reference in a new issue