Network upgrade and new reconnection mode (#11527)

Network upgrade and new reconnection mode:
* users can disconnect or close app without game progress loose now;
* disconnect dialog will show active tables stats and additional options;
* all active tables will be restored on reconnect (tables, tourneys, games, drafts, sideboarding, constructing);
* user must use same server and username on next connection;
* there are few minutes for reconnect until server kick off a disconnected player from all player's tables (concede/loose);
* now you can safety reconnect after IP change (after proxy/vpn/wifi/router restart);

Other improvements and fixes:
* gui: main menu - improved switch panel button, added stats about current tables/panels;
* gui: improved data sync and updates (fixes many use cases with empty battlefield, not started games/drafts/tourneys, not updatable drafts, etc);
* gui: improved stability on game updates (fixes some random errors related to wrong threads);
* server: fixed miss messages about player's disconnection problems for other players in the chat;
* refactor: simplified and improved connection and network related code, deleted outdated code, added docs;
* tests: improved load test to support lands only set for more stable performance/network testing (set TEST_AI_RANDOM_DECK_SETS = PELP and run test_TwoAIPlayGame_Multiple);
This commit is contained in:
Oleg Agafonov 2023-12-07 19:56:52 +03:00 committed by GitHub
parent 7f0558ff3c
commit 960e896903
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 1274 additions and 802 deletions

View file

@ -11,6 +11,7 @@ import java.util.concurrent.ExecutionException;
import javax.swing.*;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import mage.remote.SessionImpl;
import org.apache.log4j.Logger;
/**
@ -20,6 +21,7 @@ import org.apache.log4j.Logger;
public class ConnectDialog extends JDialog {
private static final Logger logger = Logger.getLogger(ConnectDialog.class);
private ConsoleFrame console;
private Connection connection;
private ConnectTask task;
@ -352,7 +354,7 @@ public class ConnectDialog extends JDialog {
connection.setHost(this.txtServer.getText());
connection.setPort(Integer.parseInt(this.txtPort.getText()));
connection.setAdminPassword(new String(txtPassword.getPassword()));
connection.setUsername("Admin");
connection.setUsername(SessionImpl.ADMIN_NAME);
connection.setProxyType((ProxyType) this.cbProxyType.getSelectedItem());
if (!this.cbProxyType.getSelectedItem().equals(ProxyType.NONE)) {
connection.setProxyHost(this.txtProxyServer.getText());

View file

@ -154,10 +154,11 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
}// </editor-fold>//GEN-END:initComponents
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
if (session.isConnected()) {
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
this.consolePanel1.stop();
session.connectStop(false);
session.connectStop(false, false);
}
} else {
connectDialog.showDialog(this);
@ -243,7 +244,13 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
}
@Override
public void processCallback(ClientCallback callback) {
public void onNewConnection() {
// ignore
}
@Override
public void onCallback(ClientCallback callback) {
// ignore
}
public void exitApp() {
@ -251,7 +258,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
if (JOptionPane.showConfirmDialog(this, "You are currently connected. Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;
}
session.connectStop(false);
session.connectStop(false, false);
} else {
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to exit?", "Confirm exit", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;