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"; + } +}