Browse Source

Merge pull request #594 in DESIGN/design from ~RICHIE/design:release/10.0 to release/10.0

* commit 'f086badbf6a0d839f5cf141d80c724b044265ffb':
  无JIRA任务  websocket端口可以支持设置多个可选端口,让单机多节点集群可用
final/10.0
richie 6 years ago
parent
commit
fc7a18ef9d
  1. 32
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

32
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -68,8 +68,8 @@ public class DesignerSocketIO {
return; return;
} }
try { try {
String uri = getSocketUri(current); String[] uri = getSocketUri(current);
socketIO = Optional.of(IO.socket(new URI(uri))); socketIO = Optional.of(IO.socket(new URI(uri[0])));
socketIO.get().on(WorkspaceConstants.WS_LOGRECORD, printLog); socketIO.get().on(WorkspaceConstants.WS_LOGRECORD, printLog);
socketIO.get().on(WorkspaceConstants.CONFIG_MODIFY, new Emitter.Listener() { socketIO.get().on(WorkspaceConstants.CONFIG_MODIFY, new Emitter.Listener() {
@Override @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()); 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(); WorkspaceConnection connection = WorkContext.getCurrent().getConnection();
return String.format("%s://%s:%s%s?%s=%s&%s=%s", String[] result = new String[ports.length];
url.getProtocol(), for (int i = 0; i < ports.length; i++ ) {
url.getHost(), result[i] = String.format("%s://%s:%s%s?%s=%s&%s=%s",
port, url.getProtocol(),
WorkspaceConstants.WS_NAMESPACE, url.getHost(),
DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, ports[i],
connection.getToken(), WorkspaceConstants.WS_NAMESPACE,
RemoteDesignConstants.USER_LOCK_ID, DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME,
connection.getId() connection.getToken(),
); RemoteDesignConstants.USER_LOCK_ID,
connection.getId());
}
return result;
} }
} }

Loading…
Cancel
Save