diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/PingRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/PingRequest.java index ae3c8ea7..d620530a 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/PingRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/PingRequest.java @@ -1,9 +1,11 @@ package ru.gravit.launcher.request; +import ru.gravit.launcher.request.websockets.StandartClientWebSocketService; + public final class PingRequest extends Request { @Override - protected ResultInterface requestDo() throws Exception { + protected ResultInterface requestDo(StandartClientWebSocketService service) throws Exception { return null; } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java index 4469ad4b..eb98f3a7 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java @@ -36,11 +36,17 @@ public R request() throws Exception { if (!started.compareAndSet(false, true)) throw new IllegalStateException("Request already started"); if(service == null) service = StandartClientWebSocketService.initWebSockets(Launcher.getConfig().address, false); - return requestDo(); + return requestDo(service); + } + @LauncherAPI + public R request(StandartClientWebSocketService service) throws Exception { + if (!started.compareAndSet(false, true)) + throw new IllegalStateException("Request already started"); + return requestDo(service); } @SuppressWarnings("unchecked") - protected R requestDo() throws Exception + protected R requestDo(StandartClientWebSocketService service) throws Exception { return (R) service.sendRequest(this); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java index 3c0be801..8980d008 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java @@ -7,6 +7,7 @@ import ru.gravit.launcher.events.request.LauncherRequestEvent; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.websockets.RequestInterface; +import ru.gravit.launcher.request.websockets.StandartClientWebSocketService; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.LogHelper; @@ -65,7 +66,7 @@ public static void update(LauncherRequestEvent result) throws IOException { } @Override - public LauncherRequestEvent requestDo() throws Exception { + public LauncherRequestEvent requestDo(StandartClientWebSocketService service) throws Exception { LauncherRequestEvent result = (LauncherRequestEvent) service.sendRequest(this); if (result.needUpdate) update(result); return result; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java index a39c21f2..c12c4ab9 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java @@ -12,6 +12,7 @@ import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.update.UpdateRequest.State.Callback; import ru.gravit.launcher.request.websockets.RequestInterface; +import ru.gravit.launcher.request.websockets.StandartClientWebSocketService; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; @@ -166,7 +167,7 @@ public double getTotalSizeMiB() { } @Override - public UpdateRequestEvent requestDo() throws Exception { + public UpdateRequestEvent requestDo(StandartClientWebSocketService service) throws Exception { LogHelper.debug("Start update request"); UpdateRequestEvent e = (UpdateRequestEvent) service.sendRequest(this); LogHelper.debug("Start update");