From f086badbf6a0d839f5cf141d80c724b044265ffb Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 13 Nov 2018 12:04:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=20websocket?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E5=8F=AF=E4=BB=A5=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=A4=9A=E4=B8=AA=E5=8F=AF=E9=80=89=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E8=AE=A9=E5=8D=95=E6=9C=BA=E5=A4=9A=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E9=9B=86=E7=BE=A4=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/socketio/DesignerSocketIO.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 132d72d17..bcf7450e1 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -68,8 +68,8 @@ public class DesignerSocketIO { return; } try { - String uri = getSocketUri(current); - socketIO = Optional.of(IO.socket(new URI(uri))); + String[] uri = getSocketUri(current); + socketIO = Optional.of(IO.socket(new URI(uri[0]))); socketIO.get().on(WorkspaceConstants.WS_LOGRECORD, printLog); socketIO.get().on(WorkspaceConstants.CONFIG_MODIFY, new Emitter.Listener() { @Override @@ -109,19 +109,23 @@ public class DesignerSocketIO { } } - private static String getSocketUri(Workspace current) throws IOException { + private static String[] getSocketUri(Workspace current) throws IOException { URL url = new URL(current.getPath()); - int port = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort(); + Integer[] ports = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort(); WorkspaceConnection connection = WorkContext.getCurrent().getConnection(); - return String.format("%s://%s:%s%s?%s=%s&%s=%s", - url.getProtocol(), - url.getHost(), - port, - WorkspaceConstants.WS_NAMESPACE, - DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, - connection.getToken(), - RemoteDesignConstants.USER_LOCK_ID, - connection.getId() - ); + 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", + url.getProtocol(), + url.getHost(), + ports[i], + WorkspaceConstants.WS_NAMESPACE, + DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, + connection.getToken(), + RemoteDesignConstants.USER_LOCK_ID, + connection.getId()); + } + return result; + } }