mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
Fixed Issue 244
This commit is contained in:
parent
928ee4036a
commit
4534f11f3d
3 changed files with 26 additions and 7 deletions
|
|
@ -554,6 +554,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
return session.connect(connection);
|
||||
}
|
||||
|
||||
public static boolean stopConnecting() {
|
||||
return session.stopConnecting();
|
||||
}
|
||||
|
||||
public boolean autoConnect() {
|
||||
boolean autoConnect = Boolean.parseBoolean(prefs.get("autoConnect", "false"));
|
||||
if (autoConnect) {
|
||||
|
|
|
|||
|
|
@ -322,7 +322,6 @@ public class ConnectDialog extends MageDialog {
|
|||
try {
|
||||
get();
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
btnConnect.setEnabled(true);
|
||||
if (result) {
|
||||
lblStatus.setText("");
|
||||
connected();
|
||||
|
|
@ -334,7 +333,13 @@ public class ConnectDialog extends MageDialog {
|
|||
logger.fatal("Update Players Task error", ex);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.fatal("Update Players Task error", ex);
|
||||
} catch (CancellationException ex) {}
|
||||
} catch (CancellationException ex) {
|
||||
logger.info("Connect was canceled");
|
||||
lblStatus.setText("Connect was canceled");
|
||||
MageFrame.stopConnecting();
|
||||
} finally {
|
||||
btnConnect.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public class Session {
|
|||
private Connection connection;
|
||||
|
||||
private static boolean debugMode = false;
|
||||
private boolean canceled = false;
|
||||
|
||||
static {
|
||||
debugMode = System.getProperty("debug.mage") != null;
|
||||
|
|
@ -92,9 +93,15 @@ public class Session {
|
|||
disconnect(true);
|
||||
}
|
||||
this.connection = connection;
|
||||
this.canceled = false;
|
||||
return connect();
|
||||
}
|
||||
|
||||
public boolean stopConnecting() {
|
||||
canceled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean connect() {
|
||||
sessionState = SessionState.CONNECTING;
|
||||
try {
|
||||
|
|
@ -171,12 +178,16 @@ public class Session {
|
|||
logger.fatal("", ex);
|
||||
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
||||
} catch (MageVersionException ex) {
|
||||
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
||||
if (!canceled) {
|
||||
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
||||
}
|
||||
// TODO: download client that matches server version
|
||||
} catch (Throwable t) {
|
||||
logger.fatal("Unable to connect to server - ", t);
|
||||
disconnect(false);
|
||||
client.showMessage("Unable to connect to server. " + t.getMessage());
|
||||
if (!canceled) {
|
||||
disconnect(false);
|
||||
client.showMessage("Unable to connect to server. " + t.getMessage());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -187,7 +198,6 @@ public class Session {
|
|||
if (connection == null)
|
||||
return;
|
||||
try {
|
||||
|
||||
callbackClient.disconnect();
|
||||
TransporterClient.destroyTransporterClient(server);
|
||||
} catch (Throwable ex) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue