mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
* Client connect - Fixed that reconnect request was also shown if no successful connection was set up before.
This commit is contained in:
parent
7e9accb0fd
commit
2c63d3bff8
6 changed files with 16 additions and 11 deletions
|
|
@ -1224,7 +1224,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected() {
|
public void disconnected(final boolean errorCall) {
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
if (SwingUtilities.isEventDispatchThread()) {
|
||||||
setStatusText("Not connected");
|
setStatusText("Not connected");
|
||||||
disableButtons();
|
disableButtons();
|
||||||
|
|
@ -1238,13 +1238,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
disableButtons();
|
disableButtons();
|
||||||
hideGames();
|
hideGames();
|
||||||
hideTables();
|
hideTables();
|
||||||
if (JOptionPane.showConfirmDialog(MageFrame.this, "The connection to server was lost. Reconnect?", "Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
if (errorCall && JOptionPane.showConfirmDialog(MageFrame.this, "The connection to server was lost. Reconnect?", "Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
// session.disconnect(false);
|
|
||||||
// tablesPane.clearChat();
|
|
||||||
if (performConnect()) {
|
if (performConnect()) {
|
||||||
enableButtons();
|
enableButtons();
|
||||||
}
|
}
|
||||||
// } else {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ public class MultiConnectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected() {
|
public void disconnected(boolean errorCall) {
|
||||||
logger.info("disconnected");
|
logger.info("disconnected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,11 +106,13 @@ public class MultiConnectTest {
|
||||||
|
|
||||||
private void connect(final int index) throws Exception {
|
private void connect(final int index) throws Exception {
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||||
|
@Override
|
||||||
public void uncaughtException(Thread t, Throwable e) {
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
logger.fatal(null, e);
|
logger.fatal(null, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String username = "player" + index;
|
String username = "player" + index;
|
||||||
ClientMock client = new ClientMock(username);
|
ClientMock client = new ClientMock(username);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ public interface MageClient extends CallbackClient {
|
||||||
|
|
||||||
MageVersion getVersion();
|
MageVersion getVersion();
|
||||||
void connected(String message);
|
void connected(String message);
|
||||||
void disconnected();
|
void disconnected(boolean errorCall);
|
||||||
void showMessage(String message);
|
void showMessage(String message);
|
||||||
void showError(String message);
|
void showError(String message);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import java.net.MalformedURLException;
|
||||||
import java.net.PasswordAuthentication;
|
import java.net.PasswordAuthentication;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
@ -310,7 +311,12 @@ public class SessionImpl implements Session {
|
||||||
logger.fatal("Unable to connect to server - ", t);
|
logger.fatal("Unable to connect to server - ", t);
|
||||||
if (!canceled) {
|
if (!canceled) {
|
||||||
disconnect(false);
|
disconnect(false);
|
||||||
client.showMessage("Unable to connect to server. " + t.getMessage());
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Unable to connect to server.\n");
|
||||||
|
for (StackTraceElement element :t.getStackTrace()) {
|
||||||
|
sb.append(element.toString()).append("\n");
|
||||||
|
}
|
||||||
|
client.showMessage(sb.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -368,7 +374,7 @@ public class SessionImpl implements Session {
|
||||||
if (sessionState == SessionState.DISCONNECTING || sessionState == SessionState.CONNECTING) {
|
if (sessionState == SessionState.DISCONNECTING || sessionState == SessionState.CONNECTING) {
|
||||||
sessionState = SessionState.DISCONNECTED;
|
sessionState = SessionState.DISCONNECTED;
|
||||||
logger.info("Disconnected ... ");
|
logger.info("Disconnected ... ");
|
||||||
client.disconnected();
|
client.disconnected(errorCall);
|
||||||
if (errorCall) {
|
if (errorCall) {
|
||||||
client.showError("Network error. You have been disconnected");
|
client.showError("Network error. You have been disconnected");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected() {
|
public void disconnected(boolean errorCall) {
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
if (SwingUtilities.isEventDispatchThread()) {
|
||||||
consolePanel1.stop();
|
consolePanel1.stop();
|
||||||
setStatusText("Not connected");
|
setStatusText("Not connected");
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class SimpleMageClient implements MageClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected() {
|
public void disconnected(boolean errorCall) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue