diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketStartCommand.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketStartCommand.java index 222729372b4..608d516dd44 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketStartCommand.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketStartCommand.java @@ -58,7 +58,7 @@ aliases = {"-w", "--websocket"}, description = "Websocket server mode", usageHelpAutoWidth = true, - footer = "@|green Copyright(c) 2018-2020|@") + footer = "@|green Copyright(c) 2018-2022|@") @Component @RequiredArgsConstructor public class WebsocketStartCommand implements Callable { @@ -75,6 +75,13 @@ public class WebsocketStartCommand implements Callable { defaultValue = "") private String configurationOption; + @Option( + names = {"--host"}, + description = "Hostname to open websocket", + paramLabel = "", + defaultValue = "localhost") + private String websocketHost; + @Option( names = {"-p", "--port"}, description = "Listening port", @@ -92,7 +99,7 @@ public Integer call() { configuration.update(configurationFile); } - launcher.runWebSocketServer(websocketPort); + launcher.runWebSocketServer(websocketHost, websocketPort); return -1; } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebSocketRunner.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebSocketRunner.java index 9f1571b0f28..f14b1378de2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebSocketRunner.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebSocketRunner.java @@ -36,11 +36,10 @@ public class WebSocketRunner { private final LanguageServerConfiguration configuration; - public void runWebSocketServer(int port) { + public void runWebSocketServer(String hostname, int port) { - String hostname = "localhost"; String contextPath = "/"; - Server server = new Server(hostname, port, contextPath, null, BSLLSWebSocketServerConfigProvider.class); + var server = new Server(hostname, port, contextPath, null, BSLLSWebSocketServerConfigProvider.class); Runtime.getRuntime().addShutdownHook(new Thread(server::stop, "bsl-websocket-server-shutdown-hook")); try {