diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/LegacyRequestBridge.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/LegacyRequestBridge.java new file mode 100644 index 00000000..03659c42 --- /dev/null +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/LegacyRequestBridge.java @@ -0,0 +1,23 @@ +package ru.gravit.launcher.request.websockets; + +import ru.gravit.launcher.request.ResultInterface; + +import java.io.IOException; + +public class LegacyRequestBridge { + public static WaitEventHandler waitEventHandler = new WaitEventHandler(); + public static ClientWebSocketService service; + public static ResultInterface sendRequest(RequestInterface request) throws IOException, InterruptedException { + WaitEventHandler.ResultEvent e = new WaitEventHandler.ResultEvent(); + e.type = request.getType(); + waitEventHandler.requests.add(e); + service.sendObject(request); + while(!e.ready) + { + e.wait(); + } + ResultInterface result = e.result; + waitEventHandler.requests.remove(e); + return result; + } +} diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WaitEventHandler.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WaitEventHandler.java index 4dd1fc61..45aa9f78 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WaitEventHandler.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/WaitEventHandler.java @@ -21,7 +21,7 @@ public void process(ResultInterface result) { } } } - public class ResultEvent + public static class ResultEvent { public ResultInterface result; public String type;