hzzz 6 years ago
parent
commit
3f69774804
  1. 14
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

14
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<Socket> 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);
}

Loading…
Cancel
Save