|
|
@ -28,8 +28,14 @@ import java.net.URL; |
|
|
|
|
|
|
|
|
|
|
|
public class DesignerSocketIO { |
|
|
|
public class DesignerSocketIO { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum Status { |
|
|
|
|
|
|
|
Connected, |
|
|
|
|
|
|
|
Disconnected, |
|
|
|
|
|
|
|
Disconnecting |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static Optional<Socket> socketIO = Optional.absent(); |
|
|
|
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() { |
|
|
|
private static final Emitter.Listener printLog = new Emitter.Listener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -47,8 +53,10 @@ public class DesignerSocketIO { |
|
|
|
|
|
|
|
|
|
|
|
public static void close() { |
|
|
|
public static void close() { |
|
|
|
if (socketIO.isPresent()) { |
|
|
|
if (socketIO.isPresent()) { |
|
|
|
|
|
|
|
status = Status.Disconnecting; |
|
|
|
socketIO.get().close(); |
|
|
|
socketIO.get().close(); |
|
|
|
socketIO = Optional.absent(); |
|
|
|
socketIO = Optional.absent(); |
|
|
|
|
|
|
|
status = Status.Disconnected; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -72,13 +80,15 @@ public class DesignerSocketIO { |
|
|
|
socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() { |
|
|
|
socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void call(Object... objects) { |
|
|
|
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"}), |
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Disconnected"}), |
|
|
|
null, 0, UIManager.getIcon("OptionPane.errorIcon")); |
|
|
|
null, 0, UIManager.getIcon("OptionPane.errorIcon")); |
|
|
|
|
|
|
|
status = Status.Disconnected; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
socketIO.get().connect(); |
|
|
|
socketIO.get().connect(); |
|
|
|
|
|
|
|
status = Status.Connected; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|