Some changes to the server console.

This commit is contained in:
LevelX2 2016-10-04 17:40:37 +02:00
parent a1123b3c0b
commit db31264538
7 changed files with 212 additions and 89 deletions

View file

@ -166,7 +166,6 @@ public interface MageServer {
GameView getGameView(UUID gameId, String sessionId, UUID playerId) throws MageException;
// priority, undo, concede, mana pool
void sendPlayerAction(PlayerAction playerAction, UUID gameId, String sessionId, Object data) throws MageException;
//tournament methods
@ -214,6 +213,8 @@ public interface MageServer {
void endUserSession(String sessionId, String userSessionId) throws MageException;
void muteUser(String sessionId, String userName, long durationMinutes) throws MageException;
void removeTable(String sessionId, UUID tableId) throws MageException;
void sendBroadcastMessage(String sessionId, String message) throws MageException;

View file

@ -27,6 +27,11 @@
*/
package mage.remote;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
import mage.MageException;
import mage.cards.decks.DeckCardLists;
import mage.cards.decks.InvalidDeckException;
@ -56,12 +61,6 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
import org.jboss.remoting.transport.socket.SocketWrapper;
import org.jboss.remoting.transporter.TransporterClient;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
*
* @author BetaSteward_at_googlemail.com
@ -103,6 +102,7 @@ public class SessionImpl implements Session {
// intended to be used with handleRemotingTaskExceptions for sharing the common exception
// handling.
public interface RemotingTask {
public boolean run() throws Throwable;
}
@ -127,8 +127,8 @@ public class SessionImpl implements Session {
} else if (cause instanceof NoSuchMethodException) {
// NoSuchMethodException is thrown on an invocation of an unknow JBoss remoting
// method, so it's likely to be because of a version incompatibility.
addMessage = "The following method is not available in the server, probably the " +
"server version is not compatible to the client: " + cause.getMessage();
addMessage = "The following method is not available in the server, probably the "
+ "server version is not compatible to the client: " + cause.getMessage();
}
if (addMessage.isEmpty()) {
logger.fatal("", ex);
@ -341,24 +341,25 @@ public class SessionImpl implements Session {
/**
* I'll explain the meaning of "secondaryBindPort" and
* "secondaryConnectPort", and maybe that will help. The Remoting
* bisocket transport creates two ServerSockets on the server. The
* "primary" ServerSocket is used to create connections used for
* ordinary invocations, e.g., a request to create a JMS consumer,
* and the "secondary" ServerSocket is used to create "control"
* connections for internal Remoting messages. The port for the
* primary ServerSocket is configured by the "serverBindPort"
* parameter, and the port for the secondary ServerSocket is, by
* default, chosen randomly. The "secondaryBindPort" parameter can
* be used to assign a specific port to the secondary ServerSocket.
* Now, if there is a translating firewall between the client and
* server, the client should be given the value of the port that is
* "secondaryConnectPort", and maybe that will help. The
* Remoting bisocket transport creates two ServerSockets on the
* server. The "primary" ServerSocket is used to create
* connections used for ordinary invocations, e.g., a request to
* create a JMS consumer, and the "secondary" ServerSocket is
* used to create "control" connections for internal Remoting
* messages. The port for the primary ServerSocket is configured
* by the "serverBindPort" parameter, and the port for the
* secondary ServerSocket is, by default, chosen randomly. The
* "secondaryBindPort" parameter can be used to assign a
* specific port to the secondary ServerSocket. Now, if there is
* a translating firewall between the client and server, the
* client should be given the value of the port that is
* translated to the actual binding port of the secondary
* ServerSocket. For example, your configuration will tell the
* secondary ServerSocket to bind to port 14000, and it will tell
* the client to connect to port 14001. It assumes that there is a
* firewall which will translate 14001 to 14000. Apparently, that's
* not happening.
* secondary ServerSocket to bind to port 14000, and it will
* tell the client to connect to port 14001. It assumes that
* there is a firewall which will translate 14001 to 14000.
* Apparently, that's not happening.
*/
// secondaryBindPort - the port to which the secondary server socket is to be bound. By default, an arbitrary port is selected.
// secondaryConnectPort - the port clients are to use to connect to the secondary server socket.
@ -1424,6 +1425,21 @@ public class SessionImpl implements Session {
return false;
}
@Override
public boolean muteUserChat(String userName, long durationMinutes) {
try {
if (isConnected()) {
server.muteUser(sessionId, userName, durationMinutes);
return true;
}
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
}
return false;
}
private void handleThrowable(Throwable t) {
logger.fatal("Communication error", t);
// Probably this can cause hanging the client under certain circumstances as the disconnect method is synchronized
@ -1456,12 +1472,12 @@ public class SessionImpl implements Session {
String email = connection.getEmail();
return email == null ? "" : email;
}
private String getAuthToken() {
String authToken = connection.getAuthToken();
return authToken == null ? "" : authToken;
}
@Override
public boolean updatePreferencesForServer(UserData userData) {
try {

View file

@ -24,7 +24,7 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
package mage.remote.interfaces;
import mage.remote.Connection;
@ -47,7 +47,7 @@ public interface Connect {
void disconnect(boolean showMessage);
void reconnect(Throwable throwable);
boolean ping();
boolean isConnected();
@ -56,5 +56,7 @@ public interface Connect {
boolean endUserSession(String userSessionId);
boolean muteUserChat(String userName, long durationMinute);
String getSessionId();
}

View file

@ -1,16 +1,16 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
@ -42,13 +42,15 @@ public class UserView implements Serializable {
private final String sessionId;
private final Date timeConnected;
private final String gameInfo;
private final String userState;
public UserView(String userName, String host, String sessionId, Date timeConnected, String gameInfo) {
public UserView(String userName, String host, String sessionId, Date timeConnected, String gameInfo, String userState) {
this.userName = userName;
this.host = host;
this.sessionId = sessionId;
this.timeConnected = timeConnected;
this.gameInfo = gameInfo;
this.userState = userState;
}
public String getUserName() {
@ -71,4 +73,8 @@ public class UserView implements Serializable {
return gameInfo;
}
public String getUserState() {
return userState;
}
}