mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FEATURE] Мост для старых Request
This commit is contained in:
parent
dd4f97313e
commit
0d804a0558
2 changed files with 24 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ public void process(ResultInterface result) {
|
|||
}
|
||||
}
|
||||
}
|
||||
public class ResultEvent
|
||||
public static class ResultEvent
|
||||
{
|
||||
public ResultInterface result;
|
||||
public String type;
|
||||
|
|
Loading…
Reference in a new issue