From 91d26907614d999b03ae934369d50cd8b0ec81ba Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Mon, 29 Apr 2019 03:30:56 +0200 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=AD=D0=BA=D1=81=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D1=84=D0=B8=D0=BA=D1=81=20=D0=B1=D0=B0=D0=B3=D0=B0=20?= =?UTF-8?q?=D1=81=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2=D0=B8?= =?UTF-8?q?=D0=B5=D0=BC=20=D1=80=D0=B5=D0=BA=D0=BE=D0=BD=D0=BD=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=B0.=20(#238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launcher/LauncherEngine.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index 6990a706..f0b096ce 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -9,6 +9,7 @@ import ru.gravit.launcher.managers.ClientGsonManager; import ru.gravit.launcher.managers.ConsoleManager; import ru.gravit.launcher.request.Request; +import ru.gravit.launcher.request.auth.RestoreSessionRequest; import ru.gravit.launcher.request.websockets.StandartClientWebSocketService; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.EnvHelper; @@ -71,11 +72,27 @@ public void start(String... args) throws Throwable { if (runtimeProvider == null) runtimeProvider = new JSRuntimeProvider(); runtimeProvider.init(false); runtimeProvider.preLoad(); - if(Request.service != null) + if(Request.service == null) { String address = Launcher.getConfig().address; LogHelper.debug("Start async connection to %s", address); Request.service = StandartClientWebSocketService.initWebSockets(address, true); + Request.service.reconnectCallback = () -> + { + LogHelper.debug("WebSocket connect closed. Try reconnect"); + try { + if (!Request.service.reconnectBlocking()) LogHelper.error("Error connecting"); + LogHelper.debug("Connect to %s", Launcher.getConfig().address); + } catch (InterruptedException e) { + e.printStackTrace(); + } + try { + RestoreSessionRequest request1 = new RestoreSessionRequest(Request.getSession()); + request1.request(); + } catch (Exception e) { + LogHelper.error(e); + } + }; } LauncherGuardManager.initGuard(false); Objects.requireNonNull(args, "args");