From ae3e824c91924d0e5d0819ea24a124cd0264f967 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 4 Apr 2019 13:50:04 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20restoreSession?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../websocket/WebSocketFrameHandler.java | 4 ++ .../socket/websocket/WebSocketService.java | 1 + .../websocket/json/auth/AuthResponse.java | 10 +++++ .../json/auth/RestoreSessionResponse.java | 32 +++++++++++++++ .../launcher/client/ClientLauncher.java | 7 ++++ .../launcher/client/FunctionalBridge.java | 4 ++ .../launcher/request/auth/AuthRequest.java | 4 ++ .../request/auth/RestoreSessionRequest.java | 40 +++++++++++++++++++ .../websockets/ClientWebSocketService.java | 1 + .../events/request/AuthRequestEvent.java | 11 +++++ .../request/RestoreSessionRequestEvent.java | 10 +++++ 11 files changed, 124 insertions(+) create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/RestoreSessionResponse.java create mode 100644 LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java create mode 100644 libLauncher/src/main/java/ru/gravit/launcher/events/request/RestoreSessionRequestEvent.java diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java index 522e46bf..71a7d370 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java @@ -21,6 +21,10 @@ public class WebSocketFrameHandler extends SimpleChannelInboundHandler implements Requ private final String auth_id; private final HWID hwid; private final String customText; + private final boolean getSession; @LauncherAPI public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid) { @@ -32,6 +33,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw this.hwid = hwid; customText = ""; auth_id = ""; + getSession = true; } @LauncherAPI @@ -42,6 +44,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw this.hwid = hwid; this.auth_id = auth_id; customText = ""; + getSession = true; } @LauncherAPI @@ -52,6 +55,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw this.hwid = hwid; this.auth_id = auth_id; this.customText = customText; + getSession = true; } @LauncherAPI diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java new file mode 100644 index 00000000..513f7a8a --- /dev/null +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java @@ -0,0 +1,40 @@ +package ru.gravit.launcher.request.auth; + +import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.request.AuthRequestEvent; +import ru.gravit.launcher.events.request.RestoreSessionRequestEvent; +import ru.gravit.launcher.request.Request; +import ru.gravit.launcher.request.websockets.LegacyRequestBridge; +import ru.gravit.launcher.request.websockets.RequestInterface; +import ru.gravit.launcher.serialize.HInput; +import ru.gravit.launcher.serialize.HOutput; + +import java.io.IOException; + +public class RestoreSessionRequest extends Request implements RequestInterface { + @LauncherNetworkAPI + public long session; + + public RestoreSessionRequest(long session) { + this.session = session; + } + @Override + public RestoreSessionRequestEvent requestWebSockets() throws IOException, InterruptedException { + return (RestoreSessionRequestEvent) LegacyRequestBridge.sendRequest(this); + } + + @Override + public Integer getLegacyType() { + return 0; + } + + @Override + protected RestoreSessionRequestEvent requestDo(HInput input, HOutput output) throws Exception { + return new RestoreSessionRequestEvent(); + } + + @Override + public String getType() { + return "restoreSession"; + } +} diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java index 14e64b36..61c656a0 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -91,6 +91,7 @@ public void registerResults() { registerResult("updateList", UpdateListRequestEvent.class); registerResult("error", ErrorRequestEvent.class); registerResult("update", UpdateRequestEvent.class); + registerResult("restoreSession", RestoreSessionRequestEvent.class); } public void registerHandler(EventHandler eventHandler) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java index 7eaa6318..98bc520d 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java @@ -24,6 +24,8 @@ public AuthRequestEvent() { public String accessToken; @LauncherNetworkAPI public String protectToken; + @LauncherNetworkAPI + public long session; public AuthRequestEvent(PlayerProfile pp, String accessToken, ClientPermissions permissions) { this.playerProfile = pp; @@ -38,6 +40,15 @@ public AuthRequestEvent(ClientPermissions permissions, PlayerProfile playerProfi this.protectToken = protectToken; } + public AuthRequestEvent(String error, ClientPermissions permissions, PlayerProfile playerProfile, String accessToken, String protectToken, long session) { + this.error = error; + this.permissions = permissions; + this.playerProfile = playerProfile; + this.accessToken = accessToken; + this.protectToken = protectToken; + this.session = session; + } + @Override public UUID getUUID() { return uuid; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/RestoreSessionRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/RestoreSessionRequestEvent.java new file mode 100644 index 00000000..8a8e21be --- /dev/null +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/RestoreSessionRequestEvent.java @@ -0,0 +1,10 @@ +package ru.gravit.launcher.events.request; + +import ru.gravit.launcher.request.ResultInterface; + +public class RestoreSessionRequestEvent implements ResultInterface { + @Override + public String getType() { + return "restoreSession"; + } +}