[FIX] Эксперементальный фикс бага с отсутствием реконнекта. (#238)

This commit is contained in:
Zaxar163 2019-04-29 03:30:56 +02:00 committed by Gravit
parent e172cb194a
commit 91d2690761

View file

@ -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");