mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
Added some more info to some logger and game messages. Removed unused method.
This commit is contained in:
parent
0f6c14bdb7
commit
1791b809db
6 changed files with 63 additions and 60 deletions
|
@ -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);
|
||||
|
|
|
@ -214,33 +214,34 @@ public class SessionImpl implements Session {
|
|||
|
||||
@Override
|
||||
public synchronized boolean connect(final Connection connection) {
|
||||
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());
|
||||
boolean registerResult;
|
||||
if (connection.getAdminPassword() == null) {
|
||||
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
|
||||
registerResult = server.connectUser(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion());
|
||||
if (registerResult) {
|
||||
server.setUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString());
|
||||
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());
|
||||
boolean registerResult;
|
||||
if (connection.getAdminPassword() == null) {
|
||||
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
|
||||
registerResult = server.connectUser(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion());
|
||||
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
|
||||
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue