|
|
|
@ -3,19 +3,15 @@ package com.fr.design.mainframe.socketio;
|
|
|
|
|
import com.fr.config.RemoteConfigEvent; |
|
|
|
|
import com.fr.decision.webservice.utils.DecisionServiceConstants; |
|
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
|
import com.fr.design.EnvChangeEntrance; |
|
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
|
import com.fr.design.env.DesignerWorkspaceInfo; |
|
|
|
|
import com.fr.design.env.DesignerWorkspaceInfoContext; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.design.mainframe.loghandler.DesignerLogger; |
|
|
|
|
import com.fr.design.mainframe.share.ui.base.MouseClickListener; |
|
|
|
|
import com.fr.design.mainframe.toast.DesignerToastMsgUtil; |
|
|
|
|
import com.fr.design.mainframe.toast.ToastMsgDialog; |
|
|
|
|
import com.fr.design.ui.util.UIUtil; |
|
|
|
|
import com.fr.design.utils.BrowseUtils; |
|
|
|
|
import com.fr.event.EventDispatcher; |
|
|
|
|
import com.fr.general.CloudCenter; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.report.RemoteDesignConstants; |
|
|
|
@ -33,24 +29,20 @@ import com.fr.workspace.Workspace;
|
|
|
|
|
import com.fr.workspace.base.WorkspaceConstants; |
|
|
|
|
import com.fr.workspace.connect.WorkspaceConnection; |
|
|
|
|
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
|
|
|
|
import com.fr.workspace.server.socket.SocketInfoOperator; |
|
|
|
|
import io.socket.client.IO; |
|
|
|
|
import io.socket.client.Socket; |
|
|
|
|
import io.socket.emitter.Emitter; |
|
|
|
|
|
|
|
|
|
import javax.net.ssl.SSLContext; |
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Cursor; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
import java.security.KeyStore; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import javax.net.ssl.SSLContext; |
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.net.URI; |
|
|
|
|
import java.net.URL; |
|
|
|
|
import java.security.KeyStore; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.Timer; |
|
|
|
|
import java.util.TimerTask; |
|
|
|
|
|
|
|
|
@ -62,7 +54,6 @@ public class DesignerSocketIO {
|
|
|
|
|
Disconnecting |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static final String WEBSOCKET_HELP_DOC = CloudCenter.getInstance().acquireUrlByKind("websocketConnect", "https://help.fanruan.com/finereport/doc-view-2512.html"); |
|
|
|
|
private static final String HTTPS = "https"; |
|
|
|
|
private static final String HTTP = "http"; |
|
|
|
|
private static Socket socket = null; |
|
|
|
@ -75,7 +66,6 @@ public class DesignerSocketIO {
|
|
|
|
|
private static int count; |
|
|
|
|
// 当前webSocket选择的协议
|
|
|
|
|
private static String currentProtocol; |
|
|
|
|
private static ToastMsgDialog dialog = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void close() { |
|
|
|
@ -142,7 +132,7 @@ public class DesignerSocketIO {
|
|
|
|
|
String certPath = connection.getCertPath(); |
|
|
|
|
String certSecretKey = connection.getCertSecretKey(); |
|
|
|
|
if (StringUtils.isBlank(certPath) || StringUtils.isBlank(certSecretKey)) { |
|
|
|
|
return SSLContexts.createDefault(); |
|
|
|
|
return SSLContexts.createDefault(); |
|
|
|
|
} |
|
|
|
|
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); |
|
|
|
|
try (FileInputStream keystore = new FileInputStream(new File(certPath))) { |
|
|
|
@ -195,7 +185,6 @@ public class DesignerSocketIO {
|
|
|
|
|
private static final Emitter.Listener failRetry = new Emitter.Listener() { |
|
|
|
|
@Override |
|
|
|
|
public void call(Object... args) { |
|
|
|
|
showConnectionLostDialog(); |
|
|
|
|
printLog(args, PrintEventLogImpl.WARN, "failed args: {}"); |
|
|
|
|
status = Status.Disconnecting; |
|
|
|
|
socket.close(); |
|
|
|
@ -262,13 +251,13 @@ public class DesignerSocketIO {
|
|
|
|
|
UIUtil.invokeLaterIfNeeded(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
if (dialog == null) { |
|
|
|
|
dialog = DesignerToastMsgUtil.createPromptDialog(createDialogContent()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!dialog.isShow()) { |
|
|
|
|
dialog.setVisible(true); |
|
|
|
|
} |
|
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
|
DesignerContext.getDesignerFrame(), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"), |
|
|
|
|
UIManager.getString("OptionPane.messageDialogTitle"), |
|
|
|
|
JOptionPane.ERROR_MESSAGE, |
|
|
|
|
UIManager.getIcon("OptionPane.errorIcon")); |
|
|
|
|
EnvChangeEntrance.getInstance().chooseEnv(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} catch (Exception e) { |
|
|
|
@ -276,23 +265,6 @@ public class DesignerSocketIO {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static JPanel createDialogContent() { |
|
|
|
|
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
jPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_WebSocket_Lost_Tip")), BorderLayout.WEST); |
|
|
|
|
UILabel hyperLinkLabel = new UILabel(Toolkit.i18nText("Fine-Design_WebSocket_Lost_Tip_HyperLink_Text")); |
|
|
|
|
hyperLinkLabel.addMouseListener(new MouseClickListener() { |
|
|
|
|
@Override |
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
BrowseUtils.browser(WEBSOCKET_HELP_DOC); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
hyperLinkLabel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0)); |
|
|
|
|
hyperLinkLabel.setForeground(Color.BLUE); |
|
|
|
|
hyperLinkLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
|
|
|
jPanel.add(hyperLinkLabel, BorderLayout.CENTER); |
|
|
|
|
return jPanel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//配置变更监听器
|
|
|
|
|
private static final Emitter.Listener modifyConfig = new Emitter.Listener() { |
|
|
|
|
@Override |
|
|
|
|