|
|
|
@ -6,6 +6,7 @@ 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.i18n.Toolkit; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.design.mainframe.loghandler.DesignerLogger; |
|
|
|
@ -127,9 +128,7 @@ public class DesignerSocketIO {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static SSLContext getSSLContext() throws Exception { |
|
|
|
|
String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); |
|
|
|
|
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); |
|
|
|
|
WorkspaceConnectionInfo connection = info.getConnection(); |
|
|
|
|
WorkspaceConnectionInfo connection = getConnectionInfo(); |
|
|
|
|
String certPath = connection.getCertPath(); |
|
|
|
|
String certSecretKey = connection.getCertSecretKey(); |
|
|
|
|
if (StringUtils.isBlank(certPath) || StringUtils.isBlank(certSecretKey)) { |
|
|
|
@ -144,6 +143,16 @@ public class DesignerSocketIO {
|
|
|
|
|
.build(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static WorkspaceConnectionInfo getConnectionInfo() { |
|
|
|
|
if (DesignerWorkspaceInfoContext.getWorkspaceInfo() == null) { |
|
|
|
|
String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); |
|
|
|
|
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); |
|
|
|
|
return info.getConnection(); |
|
|
|
|
} else { |
|
|
|
|
return DesignerWorkspaceInfoContext.getWorkspaceInfo().getConnection(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static String[] getSocketUri() throws IOException { |
|
|
|
|
Workspace current = WorkContext.getCurrent(); |
|
|
|
|
URL url = new URL(current.getPath()); |
|
|
|
@ -152,10 +161,6 @@ public class DesignerSocketIO {
|
|
|
|
|
// 服务器配置https webSocket可能是wss也可能是ws webSocket的协议可以单独配置
|
|
|
|
|
WebSocketProtocol webSocketProtocol = WebSocketConfig.getInstance().getProtocol(); |
|
|
|
|
currentProtocol = webSocketProtocol == WebSocketProtocol.PLAIN ? HTTP : HTTPS; |
|
|
|
|
if (WebSocketConfig.getInstance().isUsingProxy()) { |
|
|
|
|
// 如果配置了代理服务器跟随服务器协议
|
|
|
|
|
currentProtocol = url.getProtocol(); |
|
|
|
|
} |
|
|
|
|
String[] result = new String[ports.length]; |
|
|
|
|
for (int i = 0; i < ports.length; i++) { |
|
|
|
|
result[i] = String.format("%s://%s:%s%s?%s=%s&%s=%s", |
|
|
|
@ -239,7 +244,7 @@ public class DesignerSocketIO {
|
|
|
|
|
|
|
|
|
|
private static void showConnectionLostDialog() { |
|
|
|
|
try { |
|
|
|
|
UIUtil.invokeAndWaitIfNeeded(new Runnable() { |
|
|
|
|
UIUtil.invokeLaterIfNeeded(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
FineJOptionPane.showMessageDialog( |
|
|
|
@ -270,7 +275,7 @@ public class DesignerSocketIO {
|
|
|
|
|
for (Object object : objects) { |
|
|
|
|
if (object instanceof Throwable) { |
|
|
|
|
Throwable throwable = (Throwable) object; |
|
|
|
|
printEventLog.printThrowable(throwable.getMessage(), throwable); |
|
|
|
|
printEventLog.printThrowable(throwable); |
|
|
|
|
} else { |
|
|
|
|
printEventLog.print(prefix, object); |
|
|
|
|
} |
|
|
|
@ -278,15 +283,15 @@ public class DesignerSocketIO {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface PrintEventLog { |
|
|
|
|
void printThrowable(String s, Throwable throwable); |
|
|
|
|
void printThrowable(Throwable throwable); |
|
|
|
|
void print(String s, Object ...object); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
enum PrintEventLogImpl implements PrintEventLog { |
|
|
|
|
ERROR { |
|
|
|
|
@Override |
|
|
|
|
public void printThrowable(String s, Throwable throwable) { |
|
|
|
|
FineLoggerFactory.getLogger().error(s, throwable); |
|
|
|
|
public void printThrowable(Throwable throwable) { |
|
|
|
|
FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -297,8 +302,8 @@ public class DesignerSocketIO {
|
|
|
|
|
|
|
|
|
|
WARN { |
|
|
|
|
@Override |
|
|
|
|
public void printThrowable(String s, Throwable throwable) { |
|
|
|
|
FineLoggerFactory.getLogger().warn(s, throwable); |
|
|
|
|
public void printThrowable(Throwable throwable) { |
|
|
|
|
FineLoggerFactory.getLogger().warn(throwable.getMessage(), throwable); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|