mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 11:02:00 -08:00
Issue#424: Client now detects connection loss and asks for reconnecting
This commit is contained in:
parent
9021449970
commit
23e1f9196c
5 changed files with 67 additions and 37 deletions
|
|
@ -40,6 +40,7 @@ public interface MageClient extends CallbackClient {
|
|||
MageVersion getVersion();
|
||||
void connected(String message);
|
||||
void disconnected();
|
||||
void reconnect();
|
||||
void showMessage(String message);
|
||||
void showError(String message);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ 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.*;
|
||||
|
||||
|
|
@ -1285,7 +1286,10 @@ public class SessionImpl implements Session {
|
|||
try {
|
||||
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());
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue