Added some more info to some logger and game messages. Removed unused method.

This commit is contained in:
LevelX2 2016-11-01 23:02:11 +01:00
parent 0f6c14bdb7
commit 1791b809db
6 changed files with 63 additions and 60 deletions

View file

@ -62,16 +62,9 @@ public interface MageServer {
boolean resetPassword(String sessionId, String email, String authToken, String password) throws MageException;
// connection methods
// DEPRECATED - Use connectUser instead. This is only kept for older clients.
// This can be deleted once users transitioned to newer clients (1.4.6v1 and later).
boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException;
boolean connectUser(String userName, String password, String sessionId, MageVersion version) throws MageException;
boolean connectAdmin(String password, String sessionId, MageVersion version) throws MageException;
// Not used
// void deregisterClient(String sessionId) throws MageException;
// update methods
List<ExpansionInfo> getMissingExpansionData(List<String> codes);

View file

@ -214,7 +214,8 @@ public class SessionImpl implements Session {
@Override
public synchronized boolean connect(final Connection connection) {
return establishJBossRemotingConnection(connection) && handleRemotingTaskExceptions(new RemotingTask() {
return establishJBossRemotingConnection(connection)
&& handleRemotingTaskExceptions(new RemotingTask() {
@Override
public boolean run() throws Throwable {
logger.info("Trying to log-in as " + getUserName() + " to XMAGE server at " + connection.getHost() + ":" + connection.getPort());
@ -489,7 +490,7 @@ public class SessionImpl implements Session {
sessionState = SessionState.DISCONNECTED;
logger.info("Disconnected ... ");
if (askForReconnect) {
client.showError("Network error. You have been disconnected");
client.showError("Network error. You have been disconnected from " + connection.getHost());
}
client.disconnected(askForReconnect); // MageFrame with check to reconnect
pingTime.clear();

View file

@ -182,13 +182,6 @@ public class MageServerImpl implements MageServer {
return true;
}
@Override
public boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException {
// This method is deprecated, so just inform the server version.
logger.info("MageVersionException: userName=" + userName + ", version=" + version);
throw new MageVersionException(version, Main.getVersion());
}
@Override
public boolean connectUser(String userName, String password, String sessionId, MageVersion version) throws MageException {
try {

View file

@ -278,7 +278,7 @@ public class Main {
StringBuilder sessionInfo = new StringBuilder();
User user = UserManager.getInstance().getUser(session.getUserId());
if (user != null) {
sessionInfo.append(user.getName());
sessionInfo.append(user.getName()).append(" [").append(user.getGameInfo()).append("]");
} else {
sessionInfo.append("[user missing] ");
}
@ -309,9 +309,9 @@ public class Main {
protected Connector connector;
public MageTransporterServer(InvokerLocator locator, Object target, String subsystem, MageServerInvocationHandler callback) throws Exception {
public MageTransporterServer(InvokerLocator locator, Object target, String subsystem, MageServerInvocationHandler serverInvocationHandler) throws Exception {
super(locator, target, subsystem);
connector.addInvocationHandler("callback", callback);
connector.addInvocationHandler("callback", serverInvocationHandler);
connector.setLeasePeriod(ConfigSettings.getInstance().getLeasePeriod());
connector.addConnectionListener(new ClientConnectionListener());
}
@ -332,18 +332,45 @@ public class Main {
@Override
public void setMBeanServer(MBeanServer server) {
/**
* An MBean is a managed Java object, similar to a JavaBeans
* component, that follows the design patterns set forth in the JMX
* specification. An MBean can represent a device, an application,
* or any resource that needs to be managed. MBeans expose a
* management interface that consists of the following:
*
* A set of readable or writable attributes, or both. A set of
* invokable operations. A self-description.
*
*/
if (server != null) {
logger.info("Default domain: " + server.getDefaultDomain());
}
}
@Override
public void setInvoker(ServerInvoker invoker) {
logger.info("Invoker version: " + ((BisocketServerInvoker) invoker).getVersion());
((BisocketServerInvoker) invoker).setSecondaryBindPort(ConfigSettings.getInstance().getSecondaryBindPort());
((BisocketServerInvoker) invoker).setBacklog(ConfigSettings.getInstance().getBacklogSize());
((BisocketServerInvoker) invoker).setNumAcceptThreads(ConfigSettings.getInstance().getNumAcceptThreads());
}
@Override
public void addListener(InvokerCallbackHandler callbackHandler) {
// Called for every client connecting to the server
ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler;
try {
String sessionId = handler.getClientSessionId();
SessionManager.getInstance().createSession(sessionId, callbackHandler);
} catch (Throwable ex) {
logger.fatal("", ex);
}
}
@Override
public Object invoke(final InvocationRequest invocation) throws Throwable {
// Called for every client connecting to the server (after add Listener)
String sessionId = invocation.getSessionId();
Map map = invocation.getRequestPayload();
String host;
@ -357,17 +384,6 @@ public class Main {
return null;
}
@Override
public void addListener(InvokerCallbackHandler callbackHandler) {
ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler;
try {
String sessionId = handler.getClientSessionId();
SessionManager.getInstance().createSession(sessionId, callbackHandler);
} catch (Throwable ex) {
logger.fatal("", ex);
}
}
@Override
public void removeListener(InvokerCallbackHandler callbackHandler) {
ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler;

View file

@ -135,13 +135,13 @@ public class SessionManager {
logger.debug("DISCONNECT " + reason.toString() + " - sessionId: " + sessionId);
sessions.remove(sessionId);
switch (reason) {
case Disconnected:
case Disconnected: // regular session end
session.kill(reason);
break;
case SessionExpired:
case SessionExpired: // session ends after no reconnect happens in the defined time span
session.kill(reason);
break;
case LostConnection:
case LostConnection: // user lost connection - session expires countdaoun starts
session.userLostConnection();
break;
default:

View file

@ -141,7 +141,7 @@ public class UserManager {
@Override
public void run() {
try {
LOGGER.info("USER REMOVE - " + user.getName() + " (" + reason.toString() + ") userId: " + userId);
LOGGER.info("USER REMOVE - " + user.getName() + " (" + reason.toString() + ") userId: " + userId + " [" + user.getGameInfo() + "]");
user.remove(reason);
LOGGER.debug("USER REMOVE END - " + user.getName());
} catch (Exception ex) {