mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Keep registerClient for older clients. Rename the new version to registerClientWithPassword. Add an error message on NoSuchMethodException so that this kind of version incompatibility can be handled and informed to user.
This commit is contained in:
parent
51b4979f71
commit
787f4f010a
3 changed files with 23 additions and 5 deletions
|
@ -56,7 +56,11 @@ import mage.view.UserView;
|
|||
public interface MageServer {
|
||||
|
||||
// connection methods
|
||||
boolean registerClient(String userName, String password, String sessionId, MageVersion version) throws MageException;
|
||||
// DEPRECATED - Use registerClientWithPassword instead. This is 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 registerClientWithPassword(String userName, String password, String sessionId, MageVersion version) throws MageException;
|
||||
|
||||
boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
||||
// Not used
|
||||
|
|
|
@ -280,7 +280,7 @@ public class SessionImpl implements Session {
|
|||
boolean registerResult;
|
||||
if (connection.getAdminPassword() == null) {
|
||||
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
|
||||
registerResult = server.registerClient(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion());
|
||||
registerResult = server.registerClientWithPassword(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion());
|
||||
if (registerResult) {
|
||||
server.setUserData(connection.getUsername(), sessionId, connection.getUserData());
|
||||
}
|
||||
|
@ -304,13 +304,19 @@ public class SessionImpl implements Session {
|
|||
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
||||
} catch (UndeclaredThrowableException ex) {
|
||||
String addMessage = "";
|
||||
if (ex.getCause() instanceof InvocationFailureException) {
|
||||
InvocationFailureException exep = (InvocationFailureException) ex.getCause();
|
||||
Throwable cause = ex.getCause();
|
||||
if (cause instanceof InvocationFailureException) {
|
||||
InvocationFailureException exep = (InvocationFailureException) cause;
|
||||
if (exep.getCause() instanceof IOException) {
|
||||
if (exep.getCause().getMessage().startsWith("Field hash null is not available on current")) {
|
||||
addMessage = "Probabaly the server version is not compatible to the client. ";
|
||||
}
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
if (addMessage.isEmpty()) {
|
||||
logger.fatal("", ex);
|
||||
|
|
|
@ -106,7 +106,15 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean registerClient(String userName, String password, String sessionId, MageVersion version) throws MageException {
|
||||
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);
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_WRONG_VERSION, userName, version.toString(), Main.getVersion().toString(), sessionId);
|
||||
throw new MageVersionException(version, Main.getVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerClientWithPassword(String userName, String password, String sessionId, MageVersion version) throws MageException {
|
||||
try {
|
||||
if (version.compareTo(Main.getVersion()) != 0) {
|
||||
logger.info("MageVersionException: userName=" + userName + ", version=" + version);
|
||||
|
|
Loading…
Reference in a new issue