From 3f69774804c8e7690cfa2b03b33de4ad8010be80 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 18 Jul 2018 13:50:24 +0800 Subject: [PATCH] . --- .../mainframe/socketio/DesignerSocketIO.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 8a1f6b0ef..e8f6406ac 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -28,8 +28,14 @@ import java.net.URL; public class DesignerSocketIO { + enum Status { + Connected, + Disconnected, + Disconnecting + } + private static Optional socketIO = Optional.absent(); - public static final String CLIENT_CLOSE = "io client disconnect"; + public static Status status = Status.Disconnected; private static final Emitter.Listener printLog = new Emitter.Listener() { @Override @@ -47,8 +53,10 @@ public class DesignerSocketIO { public static void close() { if (socketIO.isPresent()) { + status = Status.Disconnecting; socketIO.get().close(); socketIO = Optional.absent(); + status = Status.Disconnected; } } @@ -72,13 +80,15 @@ public class DesignerSocketIO { socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() { @Override public void call(Object... objects) { - if (!CLIENT_CLOSE.equals(objects[0].toString())) { + if (status != Status.Disconnecting) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Disconnected"}), null, 0, UIManager.getIcon("OptionPane.errorIcon")); + status = Status.Disconnected; } } }); socketIO.get().connect(); + status = Status.Connected; } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); }