mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Added new client-server incompatible checks:
* added strict mode (client and server versions must be same, see MAGE_VERSION_MINOR_PATCH_MUST_BE_SAME); * you must enable string mode after github code changes in serializeable classes (see #4459); * added client-side version checks; * added error message on wrong version disconnects.
This commit is contained in:
parent
fa0e295932
commit
f223bdab31
6 changed files with 52 additions and 13 deletions
|
|
@ -767,7 +767,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
prepareAndShowTablesPane();
|
||||
return true;
|
||||
} else {
|
||||
showMessage("Unable connect to server");
|
||||
showMessage("Unable connect to server: " + SessionHandler.getLastConnectError());
|
||||
}
|
||||
} finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package mage.client;
|
||||
|
||||
import java.util.*;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.client.chat.LocalCommands;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
|
@ -16,19 +15,22 @@ import mage.remote.Session;
|
|||
import mage.remote.SessionImpl;
|
||||
import mage.view.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by IGOUDT on 15-9-2016.
|
||||
*/
|
||||
public final class SessionHandler {
|
||||
|
||||
private static Session session;
|
||||
private static String lastConnectError = "";
|
||||
|
||||
public static void startSession(MageFrame mageFrame) {
|
||||
|
||||
session = new SessionImpl(mageFrame);
|
||||
session.setJsonLogActive("true".equals(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_LOG_AUTO_SAVE, "true")));
|
||||
}
|
||||
|
||||
|
||||
public static void ping() {
|
||||
session.ping();
|
||||
}
|
||||
|
|
@ -46,7 +48,17 @@ public final class SessionHandler {
|
|||
}
|
||||
|
||||
public static boolean connect(Connection connection) {
|
||||
return session.connect(connection);
|
||||
lastConnectError = "";
|
||||
if (session.connect(connection)) {
|
||||
return true;
|
||||
} else {
|
||||
lastConnectError = session.getLastError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getLastConnectError() {
|
||||
return lastConnectError;
|
||||
}
|
||||
|
||||
public static boolean stopConnecting() {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import mage.cards.repository.ExpansionRepository;
|
|||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.SessionHandler;
|
||||
import mage.client.preference.MagePreferences;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.gui.countryBox.CountryItemEditor;
|
||||
|
|
@ -513,7 +514,7 @@ public class ConnectDialog extends MageDialog {
|
|||
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected() || redownloadDatabase);
|
||||
String allMAC = "";
|
||||
try {
|
||||
allMAC = connection.getMAC();
|
||||
allMAC = Connection.getMAC();
|
||||
} catch (SocketException ex) {
|
||||
}
|
||||
connection.setUserIdStr(System.getProperty("user.name") + ":" + System.getProperty("os.name") + ":" + MagePreferences.getUserNames() + ":" + allMAC);
|
||||
|
|
@ -535,6 +536,7 @@ public class ConnectDialog extends MageDialog {
|
|||
private class ConnectTask extends SwingWorker<Boolean, Void> {
|
||||
|
||||
private boolean result = false;
|
||||
private String lastConnectError = "";
|
||||
|
||||
private static final int CONNECTION_TIMEOUT_MS = 2100;
|
||||
|
||||
|
|
@ -543,6 +545,7 @@ public class ConnectDialog extends MageDialog {
|
|||
lblStatus.setText("Connecting...");
|
||||
btnConnect.setEnabled(false);
|
||||
result = MageFrame.connect(connection);
|
||||
lastConnectError = SessionHandler.getLastConnectError();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -556,7 +559,7 @@ public class ConnectDialog extends MageDialog {
|
|||
connected();
|
||||
MageFrame.getInstance().prepareAndShowTablesPane();
|
||||
} else {
|
||||
lblStatus.setText("Could not connect");
|
||||
lblStatus.setText("Could not connect: " + lastConnectError);
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("Update Players Task error", ex);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue