diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java index 1fd291bc..b13e3ade 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java @@ -16,10 +16,7 @@ import ru.gravit.launchserver.socket.websocket.json.EchoResponse; import ru.gravit.launchserver.socket.websocket.json.JsonResponseAdapter; import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface; -import ru.gravit.launchserver.socket.websocket.json.auth.AuthResponse; -import ru.gravit.launchserver.socket.websocket.json.auth.CheckServerResponse; -import ru.gravit.launchserver.socket.websocket.json.auth.JoinServerResponse; -import ru.gravit.launchserver.socket.websocket.json.auth.ProfilesResponse; +import ru.gravit.launchserver.socket.websocket.json.auth.*; import ru.gravit.launchserver.socket.websocket.json.update.LauncherResponse; import ru.gravit.launchserver.socket.websocket.json.update.UpdateListResponse; import ru.gravit.utils.helper.LogHelper; @@ -78,6 +75,7 @@ public void registerResponses() { registerResponse("launcher", LauncherResponse.class); registerResponse("updateList", UpdateListResponse.class); registerResponse("cmdExec", UpdateListResponse.class); + registerResponse("setProfile", SetProfileResponse.class); } public void sendObject(ChannelHandlerContext ctx, Object obj) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/SetProfileResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/SetProfileResponse.java index dfe4e156..c12b5053 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/SetProfileResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/SetProfileResponse.java @@ -2,6 +2,7 @@ import io.netty.channel.ChannelHandlerContext; import ru.gravit.launcher.events.request.ErrorRequestEvent; +import ru.gravit.launcher.events.request.SetProfileRequestEvent; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.socket.Client; @@ -32,8 +33,8 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client return; } client.profile = p; - service.sendObject(ctx, new WebSocketService.SuccessResult(getType())); - break; + service.sendObject(ctx, new SetProfileRequestEvent(p)); + return; } } service.sendObject(ctx, new ErrorRequestEvent("Profile not found")); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/SetProfileRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/SetProfileRequest.java index 4dee1fd2..a0872d82 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/SetProfileRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/SetProfileRequest.java @@ -1,30 +1,45 @@ package ru.gravit.launcher.request.auth; import ru.gravit.launcher.LauncherConfig; +import ru.gravit.launcher.events.request.SetProfileRequestEvent; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.RequestType; +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 ru.gravit.launcher.serialize.SerializeLimits; -public class SetProfileRequest extends Request { - private ClientProfile profile; +public class SetProfileRequest extends Request implements RequestInterface { + private transient ClientProfile profile; + + public String client; public SetProfileRequest(LauncherConfig config, ClientProfile profile) { super(config); this.profile = profile; + this.client = profile.getTitle(); + } + @Override + public SetProfileRequestEvent requestWebSockets() throws Exception + { + return (SetProfileRequestEvent) LegacyRequestBridge.sendRequest(this); } - @Override public Integer getLegacyType() { return RequestType.SETPROFILE.getNumber(); } @Override - protected Boolean requestDo(HInput input, HOutput output) throws Exception { + protected SetProfileRequestEvent requestDo(HInput input, HOutput output) throws Exception { output.writeString(profile.getTitle(), SerializeLimits.MAX_CLIENT); readError(input); - return input.readBoolean(); + return new SetProfileRequestEvent(profile); + } + + @Override + public String getType() { + return "setProfile"; } } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/SetProfileRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/SetProfileRequestEvent.java new file mode 100644 index 00000000..5a0ba168 --- /dev/null +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/SetProfileRequestEvent.java @@ -0,0 +1,26 @@ +package ru.gravit.launcher.events.request; + +import ru.gravit.launcher.profiles.ClientProfile; +import ru.gravit.launcher.request.ResultInterface; +import ru.gravit.utils.event.EventInterface; + +import java.util.UUID; + +public class SetProfileRequestEvent implements ResultInterface, EventInterface { + private static final UUID uuid = UUID.fromString("08c0de9e-4364-4152-9066-8354a3a48541"); + public ClientProfile newProfile; + + public SetProfileRequestEvent(ClientProfile newProfile) { + this.newProfile = newProfile; + } + + @Override + public String getType() { + return "setProfile"; + } + + @Override + public UUID getUUID() { + return uuid; + } +}