mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Поддержка множества WebSocket соеденений
This commit is contained in:
parent
b5014175d0
commit
32e8065f4c
4 changed files with 15 additions and 5 deletions
|
@ -1,9 +1,11 @@
|
|||
package ru.gravit.launcher.request;
|
||||
|
||||
import ru.gravit.launcher.request.websockets.StandartClientWebSocketService;
|
||||
|
||||
public final class PingRequest extends Request<ResultInterface> {
|
||||
|
||||
@Override
|
||||
protected ResultInterface requestDo() throws Exception {
|
||||
protected ResultInterface requestDo(StandartClientWebSocketService service) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue