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; 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 connectUser(String userName, String password, String sessionId, MageVersion version) throws MageException;
boolean connectAdmin(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 // update methods
List<ExpansionInfo> getMissingExpansionData(List<String> codes); List<ExpansionInfo> getMissingExpansionData(List<String> codes);

View file

@ -214,33 +214,34 @@ public class SessionImpl implements Session {
@Override @Override
public synchronized boolean connect(final Connection connection) { public synchronized boolean connect(final Connection connection) {
return establishJBossRemotingConnection(connection) && handleRemotingTaskExceptions(new RemotingTask() { return establishJBossRemotingConnection(connection)
@Override && handleRemotingTaskExceptions(new RemotingTask() {
public boolean run() throws Throwable { @Override
logger.info("Trying to log-in as " + getUserName() + " to XMAGE server at " + connection.getHost() + ":" + connection.getPort()); public boolean run() throws Throwable {
boolean registerResult; logger.info("Trying to log-in as " + getUserName() + " to XMAGE server at " + connection.getHost() + ":" + connection.getPort());
if (connection.getAdminPassword() == null) { boolean registerResult;
// for backward compatibility. don't remove twice call - first one does nothing but for version checking if (connection.getAdminPassword() == null) {
registerResult = server.connectUser(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion()); // for backward compatibility. don't remove twice call - first one does nothing but for version checking
if (registerResult) { registerResult = server.connectUser(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion());
server.setUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString()); if (registerResult) {
server.setUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString());
}
} else {
registerResult = server.connectAdmin(connection.getAdminPassword(), sessionId, client.getVersion());
}
if (registerResult) {
serverState = server.getServerState();
if (!connection.getUsername().equals("Admin")) {
updateDatabase(connection.isForceDBComparison(), serverState);
}
logger.info("Logged-in as " + getUserName() + " to MAGE server at " + connection.getHost() + ":" + connection.getPort());
client.connected(getUserName() + "@" + connection.getHost() + ":" + connection.getPort() + " ");
return true;
}
disconnect(false);
return false;
} }
} else { });
registerResult = server.connectAdmin(connection.getAdminPassword(), sessionId, client.getVersion());
}
if (registerResult) {
serverState = server.getServerState();
if (!connection.getUsername().equals("Admin")) {
updateDatabase(connection.isForceDBComparison(), serverState);
}
logger.info("Logged-in as " + getUserName() + " to MAGE server at " + connection.getHost() + ":" + connection.getPort());
client.connected(getUserName() + "@" + connection.getHost() + ":" + connection.getPort() + " ");
return true;
}
disconnect(false);
return false;
}
});
} }
@Override @Override
@ -489,7 +490,7 @@ public class SessionImpl implements Session {
sessionState = SessionState.DISCONNECTED; sessionState = SessionState.DISCONNECTED;
logger.info("Disconnected ... "); logger.info("Disconnected ... ");
if (askForReconnect) { 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 client.disconnected(askForReconnect); // MageFrame with check to reconnect
pingTime.clear(); pingTime.clear();

View file

@ -182,13 +182,6 @@ public class MageServerImpl implements MageServer {
return true; 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 @Override
public boolean connectUser(String userName, String password, String sessionId, MageVersion version) throws MageException { public boolean connectUser(String userName, String password, String sessionId, MageVersion version) throws MageException {
try { try {

View file

@ -278,7 +278,7 @@ public class Main {
StringBuilder sessionInfo = new StringBuilder(); StringBuilder sessionInfo = new StringBuilder();
User user = UserManager.getInstance().getUser(session.getUserId()); User user = UserManager.getInstance().getUser(session.getUserId());
if (user != null) { if (user != null) {
sessionInfo.append(user.getName()); sessionInfo.append(user.getName()).append(" [").append(user.getGameInfo()).append("]");
} else { } else {
sessionInfo.append("[user missing] "); sessionInfo.append("[user missing] ");
} }
@ -309,9 +309,9 @@ public class Main {
protected Connector connector; 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); super(locator, target, subsystem);
connector.addInvocationHandler("callback", callback); connector.addInvocationHandler("callback", serverInvocationHandler);
connector.setLeasePeriod(ConfigSettings.getInstance().getLeasePeriod()); connector.setLeasePeriod(ConfigSettings.getInstance().getLeasePeriod());
connector.addConnectionListener(new ClientConnectionListener()); connector.addConnectionListener(new ClientConnectionListener());
} }
@ -332,18 +332,45 @@ public class Main {
@Override @Override
public void setMBeanServer(MBeanServer server) { 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 @Override
public void setInvoker(ServerInvoker invoker) { public void setInvoker(ServerInvoker invoker) {
logger.info("Invoker version: " + ((BisocketServerInvoker) invoker).getVersion());
((BisocketServerInvoker) invoker).setSecondaryBindPort(ConfigSettings.getInstance().getSecondaryBindPort()); ((BisocketServerInvoker) invoker).setSecondaryBindPort(ConfigSettings.getInstance().getSecondaryBindPort());
((BisocketServerInvoker) invoker).setBacklog(ConfigSettings.getInstance().getBacklogSize()); ((BisocketServerInvoker) invoker).setBacklog(ConfigSettings.getInstance().getBacklogSize());
((BisocketServerInvoker) invoker).setNumAcceptThreads(ConfigSettings.getInstance().getNumAcceptThreads()); ((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 @Override
public Object invoke(final InvocationRequest invocation) throws Throwable { public Object invoke(final InvocationRequest invocation) throws Throwable {
// Called for every client connecting to the server (after add Listener)
String sessionId = invocation.getSessionId(); String sessionId = invocation.getSessionId();
Map map = invocation.getRequestPayload(); Map map = invocation.getRequestPayload();
String host; String host;
@ -357,17 +384,6 @@ public class Main {
return null; 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 @Override
public void removeListener(InvokerCallbackHandler callbackHandler) { public void removeListener(InvokerCallbackHandler callbackHandler) {
ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler; ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler;

View file

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

View file

@ -141,7 +141,7 @@ public class UserManager {
@Override @Override
public void run() { public void run() {
try { 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); user.remove(reason);
LOGGER.debug("USER REMOVE END - " + user.getName()); LOGGER.debug("USER REMOVE END - " + user.getName());
} catch (Exception ex) { } catch (Exception ex) {