mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FIX] Исправлена роблема с reconnectCallback
This commit is contained in:
parent
27b54cccba
commit
d008dc7217
2 changed files with 20 additions and 26 deletions
|
@ -157,21 +157,19 @@ public void run(String... args) throws Throwable {
|
||||||
else mainClass = Class.forName(classname);
|
else mainClass = Class.forName(classname);
|
||||||
MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class));
|
MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class));
|
||||||
modulesManager.postInitModules();
|
modulesManager.postInitModules();
|
||||||
if (config.websocket.enabled) {
|
|
||||||
Request.service.reconnectCallback = () ->
|
Request.service.reconnectCallback = () ->
|
||||||
{
|
{
|
||||||
LogHelper.debug("WebSocket connect closed. Try reconnect");
|
LogHelper.debug("WebSocket connect closed. Try reconnect");
|
||||||
try {
|
try {
|
||||||
Request.service.open();
|
Request.service.open();
|
||||||
LogHelper.debug("Connect to %s", config.websocket.address);
|
LogHelper.debug("Connect to %s", config.address);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
throw new RequestException(String.format("Connect error: %s", e.getMessage() != null ? e.getMessage() : "null"));
|
throw new RequestException(String.format("Connect error: %s", e.getMessage() != null ? e.getMessage() : "null"));
|
||||||
}
|
}
|
||||||
auth();
|
auth();
|
||||||
};
|
};
|
||||||
}
|
LogHelper.info("ServerWrapper: Project %s, LaunchServer address: %s. Title: %s", config.projectname, config.address, config.title);
|
||||||
LogHelper.info("ServerWrapper: Project %s, LaunchServer address: %s. Title: %s", config.projectname, config.websocket.address, config.title);
|
|
||||||
LogHelper.info("Minecraft Version (for profile): %s", wrapper.profile == null ? "unknown" : wrapper.profile.getVersion().name);
|
LogHelper.info("Minecraft Version (for profile): %s", wrapper.profile == null ? "unknown" : wrapper.profile.getVersion().name);
|
||||||
LogHelper.info("Start Minecraft Server");
|
LogHelper.info("Start Minecraft Server");
|
||||||
LogHelper.debug("Invoke main method %s", mainClass.getName());
|
LogHelper.debug("Invoke main method %s", mainClass.getName());
|
||||||
|
@ -192,11 +190,9 @@ public void updateLauncherConfig() {
|
||||||
|
|
||||||
LauncherConfig cfg = null;
|
LauncherConfig cfg = null;
|
||||||
try {
|
try {
|
||||||
cfg = new LauncherConfig(config.websocket.address, SecurityHelper.toPublicRSAKey(IOHelper.read(publicKeyFile)), new HashMap<>(), config.projectname);
|
cfg = new LauncherConfig(config.address, SecurityHelper.toPublicRSAKey(IOHelper.read(publicKeyFile)), new HashMap<>(), config.projectname);
|
||||||
if (config.websocket != null && config.websocket.enabled) {
|
|
||||||
cfg.isNettyEnabled = true;
|
cfg.isNettyEnabled = true;
|
||||||
cfg.address = config.websocket.address;
|
cfg.address = config.address;
|
||||||
}
|
|
||||||
} catch (InvalidKeySpecException | IOException e) {
|
} catch (InvalidKeySpecException | IOException e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
}
|
}
|
||||||
|
@ -228,8 +224,7 @@ public Config getDefaultConfig() {
|
||||||
newConfig.reconnectCount = 10;
|
newConfig.reconnectCount = 10;
|
||||||
newConfig.reconnectSleep = 1000;
|
newConfig.reconnectSleep = 1000;
|
||||||
newConfig.websocket = new WebSocketConf();
|
newConfig.websocket = new WebSocketConf();
|
||||||
newConfig.websocket.address = "ws://localhost:9274/api";
|
newConfig.address = "ws://localhost:9274/api";
|
||||||
newConfig.websocket.enabled = false;
|
|
||||||
newConfig.env = LauncherConfig.LauncherEnvironment.STD;
|
newConfig.env = LauncherConfig.LauncherEnvironment.STD;
|
||||||
return newConfig;
|
return newConfig;
|
||||||
}
|
}
|
||||||
|
@ -242,6 +237,7 @@ public void setConfig(Config config) {
|
||||||
public static final class Config {
|
public static final class Config {
|
||||||
public String title;
|
public String title;
|
||||||
public String projectname;
|
public String projectname;
|
||||||
|
public String address;
|
||||||
public WebSocketConf websocket;
|
public WebSocketConf websocket;
|
||||||
public int reconnectCount;
|
public int reconnectCount;
|
||||||
public int reconnectSleep;
|
public int reconnectSleep;
|
||||||
|
@ -261,8 +257,6 @@ public static final class Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class WebSocketConf {
|
public static final class WebSocketConf {
|
||||||
public boolean enabled;
|
|
||||||
public String address;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientProfile profile;
|
public ClientProfile profile;
|
||||||
|
|
|
@ -41,10 +41,10 @@ public void run() throws IOException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogHelper.info("Found MainClass %s", mainClassName);
|
LogHelper.info("Found MainClass %s", mainClassName);
|
||||||
System.out.println("Print launchserver websocket host:");
|
System.out.println("Print launchserver websocket host( ws://host:port/api ):");
|
||||||
String address = commands.commandHandler.readLine();
|
String address = commands.commandHandler.readLine();
|
||||||
wrapper.config.mainclass = mainClassName;
|
wrapper.config.mainclass = mainClassName;
|
||||||
wrapper.config.websocket.address = address;
|
wrapper.config.address = address;
|
||||||
if (!Files.exists(ServerWrapper.publicKeyFile)) {
|
if (!Files.exists(ServerWrapper.publicKeyFile)) {
|
||||||
LogHelper.error("public.key not found");
|
LogHelper.error("public.key not found");
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
|
|
Loading…
Reference in a new issue