diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateListResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateListResponse.java index fa4d484a..7bffcf3a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateListResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/UpdateListResponse.java @@ -4,13 +4,17 @@ import ru.gravit.launcher.events.request.ErrorRequestEvent; import ru.gravit.launcher.events.request.UpdateListRequestEvent; import ru.gravit.launcher.hasher.HashedDir; +import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.socket.websocket.WebSocketService; import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + public class UpdateListResponse implements JsonResponseInterface { - public String dir; @Override public String getType() { @@ -23,8 +27,10 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client service.sendObject(ctx, new ErrorRequestEvent("Access denied")); return; } - HashedDir hdir = LaunchServer.server.updatesDirMap.get(dir).object; - service.sendObject(ctx, new UpdateListRequestEvent(hdir)); + HashSet set = new HashSet<>(); + for(Map.Entry> entry : LaunchServer.server.updatesDirMap.entrySet()) + set.add(entry.getKey()); + service.sendObject(ctx, new UpdateListRequestEvent(set)); } } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java index 4581e8e1..342c6ed0 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java @@ -2,8 +2,11 @@ import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; +import ru.gravit.launcher.events.request.UpdateListRequestEvent; 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.utils.helper.IOHelper; @@ -13,7 +16,7 @@ import java.util.HashSet; import java.util.Set; -public final class UpdateListRequest extends Request> { +public final class UpdateListRequest extends Request implements RequestInterface { @LauncherAPI public UpdateListRequest() { this(null); @@ -24,21 +27,32 @@ public UpdateListRequest(LauncherConfig config) { super(config); } + @Override + public UpdateListRequestEvent requestWebSockets() throws Exception + { + return (UpdateListRequestEvent) LegacyRequestBridge.sendRequest(this); + } + @Override public Integer getLegacyType() { return RequestType.UPDATE_LIST.getNumber(); } @Override - protected Set requestDo(HInput input, HOutput output) throws IOException { + protected UpdateListRequestEvent requestDo(HInput input, HOutput output) throws IOException { int count = input.readLength(0); // Read all update dirs names - Set result = new HashSet<>(count); + HashSet result = new HashSet<>(count); for (int i = 0; i < count; i++) result.add(IOHelper.verifyFileName(input.readString(255))); // We're done. Make it unmodifiable and return - return Collections.unmodifiableSet(result); + return new UpdateListRequestEvent(result); + } + + @Override + public String getType() { + return "updateList"; } } 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 580ee517..98629b59 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 @@ -85,6 +85,7 @@ public void registerResults() { registerResult("profileByUUID", ProfileByUUIDRequestEvent.class); registerResult("batchProfileByUsername", BatchProfileByUsernameRequestEvent.class); registerResult("profiles", ProfilesRequestEvent.class); + registerResult("setProfile", SetProfileRequestEvent.class); registerResult("updateList", UpdateListRequestEvent.class); registerResult("error", ErrorRequestEvent.class); } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java index fa51be8b..fc2d5f67 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java @@ -5,18 +5,17 @@ import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; +import java.util.ArrayList; +import java.util.HashSet; import java.util.UUID; public class UpdateListRequestEvent implements EventInterface, ResultInterface { private static final UUID uuid = UUID.fromString("5fa836ae-6b61-401c-96ac-d8396f07ec6b"); @LauncherNetworkAPI - public final String type; - @LauncherNetworkAPI - public final HashedDir dir; + public final HashSet dirs; - public UpdateListRequestEvent(HashedDir dir) { - this.dir = dir; - type = "success"; + public UpdateListRequestEvent(HashSet dirs) { + this.dirs = dirs; } @Override public UUID getUUID() {