|
|
@ -3,19 +3,15 @@ package com.fr.design.mainframe.socketio; |
|
|
|
import com.fr.config.RemoteConfigEvent; |
|
|
|
import com.fr.config.RemoteConfigEvent; |
|
|
|
import com.fr.decision.webservice.utils.DecisionServiceConstants; |
|
|
|
import com.fr.decision.webservice.utils.DecisionServiceConstants; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
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.DesignerWorkspaceInfo; |
|
|
|
import com.fr.design.env.DesignerWorkspaceInfoContext; |
|
|
|
import com.fr.design.env.DesignerWorkspaceInfoContext; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
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.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.ui.util.UIUtil; |
|
|
|
import com.fr.design.utils.BrowseUtils; |
|
|
|
|
|
|
|
import com.fr.event.EventDispatcher; |
|
|
|
import com.fr.event.EventDispatcher; |
|
|
|
import com.fr.general.CloudCenter; |
|
|
|
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.report.RemoteDesignConstants; |
|
|
|
import com.fr.report.RemoteDesignConstants; |
|
|
@ -33,24 +29,20 @@ import com.fr.workspace.Workspace; |
|
|
|
import com.fr.workspace.base.WorkspaceConstants; |
|
|
|
import com.fr.workspace.base.WorkspaceConstants; |
|
|
|
import com.fr.workspace.connect.WorkspaceConnection; |
|
|
|
import com.fr.workspace.connect.WorkspaceConnection; |
|
|
|
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
|
|
|
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
|
|
|
|
|
|
|
import com.fr.workspace.server.socket.SocketInfoOperator; |
|
|
|
import io.socket.client.IO; |
|
|
|
import io.socket.client.IO; |
|
|
|
import io.socket.client.Socket; |
|
|
|
import io.socket.client.Socket; |
|
|
|
import io.socket.emitter.Emitter; |
|
|
|
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.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
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.io.IOException; |
|
|
|
import java.net.URI; |
|
|
|
import java.net.URI; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
import java.security.KeyStore; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.Timer; |
|
|
|
import java.util.Timer; |
|
|
|
import java.util.TimerTask; |
|
|
|
import java.util.TimerTask; |
|
|
|
|
|
|
|
|
|
|
@ -62,7 +54,6 @@ public class DesignerSocketIO { |
|
|
|
Disconnecting |
|
|
|
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 HTTPS = "https"; |
|
|
|
private static final String HTTP = "http"; |
|
|
|
private static final String HTTP = "http"; |
|
|
|
private static Socket socket = null; |
|
|
|
private static Socket socket = null; |
|
|
@ -75,7 +66,6 @@ public class DesignerSocketIO { |
|
|
|
private static int count; |
|
|
|
private static int count; |
|
|
|
// 当前webSocket选择的协议
|
|
|
|
// 当前webSocket选择的协议
|
|
|
|
private static String currentProtocol; |
|
|
|
private static String currentProtocol; |
|
|
|
private static ToastMsgDialog dialog = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void close() { |
|
|
|
public static void close() { |
|
|
@ -143,7 +133,7 @@ public class DesignerSocketIO { |
|
|
|
String certPath = connection.getCertPath(); |
|
|
|
String certPath = connection.getCertPath(); |
|
|
|
String certSecretKey = connection.getCertSecretKey(); |
|
|
|
String certSecretKey = connection.getCertSecretKey(); |
|
|
|
if (StringUtils.isBlank(certPath) || StringUtils.isBlank(certSecretKey)) { |
|
|
|
if (StringUtils.isBlank(certPath) || StringUtils.isBlank(certSecretKey)) { |
|
|
|
return SSLContexts.createDefault(); |
|
|
|
return SSLContexts.createDefault(); |
|
|
|
} |
|
|
|
} |
|
|
|
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); |
|
|
|
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); |
|
|
|
try (FileInputStream keystore = new FileInputStream(new File(certPath))) { |
|
|
|
try (FileInputStream keystore = new FileInputStream(new File(certPath))) { |
|
|
@ -196,7 +186,6 @@ public class DesignerSocketIO { |
|
|
|
private static final Emitter.Listener failRetry = new Emitter.Listener() { |
|
|
|
private static final Emitter.Listener failRetry = new Emitter.Listener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void call(Object... args) { |
|
|
|
public void call(Object... args) { |
|
|
|
showConnectionLostDialog(); |
|
|
|
|
|
|
|
printLog(args, PrintEventLogImpl.WARN, "failed args: {}"); |
|
|
|
printLog(args, PrintEventLogImpl.WARN, "failed args: {}"); |
|
|
|
status = Status.Disconnecting; |
|
|
|
status = Status.Disconnecting; |
|
|
|
socket.close(); |
|
|
|
socket.close(); |
|
|
@ -263,13 +252,13 @@ public class DesignerSocketIO { |
|
|
|
UIUtil.invokeLaterIfNeeded(new Runnable() { |
|
|
|
UIUtil.invokeLaterIfNeeded(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
if (dialog == null) { |
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
dialog = DesignerToastMsgUtil.createPromptDialog(createDialogContent()); |
|
|
|
DesignerContext.getDesignerFrame(), |
|
|
|
} |
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"), |
|
|
|
|
|
|
|
UIManager.getString("OptionPane.messageDialogTitle"), |
|
|
|
if (!dialog.isShow()) { |
|
|
|
JOptionPane.ERROR_MESSAGE, |
|
|
|
dialog.setVisible(true); |
|
|
|
UIManager.getIcon("OptionPane.errorIcon")); |
|
|
|
} |
|
|
|
EnvChangeEntrance.getInstance().chooseEnv(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -277,23 +266,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() { |
|
|
|
private static final Emitter.Listener modifyConfig = new Emitter.Listener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|