fixed auto reconnect feature

This commit is contained in:
North 2014-05-28 08:35:10 +03:00
parent 7e7a17e1d7
commit 2b8afe379a
6 changed files with 12 additions and 34 deletions

View file

@ -949,16 +949,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
System.exit(0);
}
@Override
public void reconnect() {
session.disconnect(false);
tablesPane.clearChat();
disableButtons();
if (performConnect()) {
enableButtons();
}
}
public void enableButtons() {
btnConnect.setEnabled(true);
btnConnect.setText("Disconnect");
@ -1221,10 +1211,18 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setStatusText("Not connected");
disableButtons();
hideGames();
hideTables();
disableButtons();
if (JOptionPane.showConfirmDialog(null, "The connection to server was lost. Reconnect?", "Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
session.disconnect(false);
tablesPane.clearChat();
if (performConnect()) {
enableButtons();
}
} else {
setStatusText("Not connected");
hideGames();
hideTables();
}
}
});
}

View file

@ -74,11 +74,6 @@ public class MultiConnectTest {
logger.info("disconnected");
}
@Override
public void reconnect() {
logger.info("Not implemented");
}
@Override
public void showMessage(String message) {
logger.info("showMessage: " + message);

View file

@ -40,7 +40,6 @@ public interface MageClient extends CallbackClient {
MageVersion getVersion();
void connected(String message);
void disconnected();
void reconnect();
void showMessage(String message);
void showError(String message);

View file

@ -54,7 +54,6 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
import org.jboss.remoting.transport.socket.SocketWrapper;
import org.jboss.remoting.transporter.TransporterClient;
import javax.swing.*;
import java.net.*;
import java.util.*;
import mage.constants.ManaType;
@ -1318,9 +1317,6 @@ public class SessionImpl implements Session {
if (isConnected()) {
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());
if (JOptionPane.showConfirmDialog(null, "The connection to server was lost. Reconnect?", "Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
client.reconnect();
}
}
}
return true;

View file

@ -257,11 +257,6 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
}
}
@Override
public void reconnect() {
logger.info("Not implemented.");
}
@Override
public void showMessage(final String message) {
if (SwingUtilities.isEventDispatchThread()) {

View file

@ -42,11 +42,6 @@ public class SimpleMageClient implements MageClient {
// do nothing
}
@Override
public void reconnect() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void showMessage(String message) {
log.info(message);