mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
fixed auto reconnect feature
This commit is contained in:
parent
7e7a17e1d7
commit
2b8afe379a
6 changed files with 12 additions and 34 deletions
|
|
@ -949,16 +949,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnect() {
|
|
||||||
session.disconnect(false);
|
|
||||||
tablesPane.clearChat();
|
|
||||||
disableButtons();
|
|
||||||
if (performConnect()) {
|
|
||||||
enableButtons();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableButtons() {
|
public void enableButtons() {
|
||||||
btnConnect.setEnabled(true);
|
btnConnect.setEnabled(true);
|
||||||
btnConnect.setText("Disconnect");
|
btnConnect.setText("Disconnect");
|
||||||
|
|
@ -1221,10 +1211,18 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
setStatusText("Not connected");
|
disableButtons();
|
||||||
disableButtons();
|
if (JOptionPane.showConfirmDialog(null, "The connection to server was lost. Reconnect?", "Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
hideGames();
|
session.disconnect(false);
|
||||||
hideTables();
|
tablesPane.clearChat();
|
||||||
|
if (performConnect()) {
|
||||||
|
enableButtons();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setStatusText("Not connected");
|
||||||
|
hideGames();
|
||||||
|
hideTables();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,6 @@ public class MultiConnectTest {
|
||||||
logger.info("disconnected");
|
logger.info("disconnected");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnect() {
|
|
||||||
logger.info("Not implemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showMessage(String message) {
|
public void showMessage(String message) {
|
||||||
logger.info("showMessage: " + message);
|
logger.info("showMessage: " + message);
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ public interface MageClient extends CallbackClient {
|
||||||
MageVersion getVersion();
|
MageVersion getVersion();
|
||||||
void connected(String message);
|
void connected(String message);
|
||||||
void disconnected();
|
void disconnected();
|
||||||
void reconnect();
|
|
||||||
void showMessage(String message);
|
void showMessage(String message);
|
||||||
void showError(String message);
|
void showError(String message);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
|
||||||
import org.jboss.remoting.transport.socket.SocketWrapper;
|
import org.jboss.remoting.transport.socket.SocketWrapper;
|
||||||
import org.jboss.remoting.transporter.TransporterClient;
|
import org.jboss.remoting.transporter.TransporterClient;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
|
|
@ -1318,9 +1317,6 @@ public class SessionImpl implements Session {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
if (!server.ping(sessionId)) {
|
if (!server.ping(sessionId)) {
|
||||||
logger.error(new StringBuilder("Ping failed: ").append(this.getUserName()).append(" Session: ").append(sessionId).append(" to MAGE server at ").append(connection.getHost()).append(":").append(connection.getPort()).toString());
|
logger.error(new StringBuilder("Ping failed: ").append(this.getUserName()).append(" Session: ").append(sessionId).append(" to MAGE server at ").append(connection.getHost()).append(":").append(connection.getPort()).toString());
|
||||||
if (JOptionPane.showConfirmDialog(null, "The connection to server was lost. Reconnect?", "Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
|
||||||
client.reconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -257,11 +257,6 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnect() {
|
|
||||||
logger.info("Not implemented.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showMessage(final String message) {
|
public void showMessage(final String message) {
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
if (SwingUtilities.isEventDispatchThread()) {
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,6 @@ public class SimpleMageClient implements MageClient {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnect() {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showMessage(String message) {
|
public void showMessage(String message) {
|
||||||
log.info(message);
|
log.info(message);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue