[FEATURE] Add ProfilesResponse WebSockets

This commit is contained in:
Gravit 2019-01-28 20:33:39 +07:00
parent 01d6587c11
commit 9ea4c051d5
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 35 additions and 0 deletions

View file

@ -17,6 +17,7 @@
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.update.LauncherResponse;
import ru.gravit.launchserver.socket.websocket.json.update.UpdateListResponse;
import ru.gravit.utils.helper.LogHelper;
@ -69,6 +70,7 @@ public void registerResponses() {
registerResponse("auth", AuthResponse.class);
registerResponse("checkServer", CheckServerResponse.class);
registerResponse("joinServer", JoinServerResponse.class);
registerResponse("profiles", ProfilesResponse.class);
registerResponse("launcherUpdate", LauncherResponse.class);
registerResponse("updateList", UpdateListResponse.class);
registerResponse("cmdExec", UpdateListResponse.class);

View file

@ -0,0 +1,33 @@
package ru.gravit.launchserver.socket.websocket.json.auth;
import io.netty.channel.ChannelHandlerContext;
import ru.gravit.launcher.profiles.ClientProfile;
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.List;
public class ProfilesResponse implements JsonResponseInterface {
@Override
public String getType() {
return "profiles";
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
service.sendObject(ctx, new Result((List<ClientProfile>) LaunchServer.server.getProfiles()));
}
public class Result
{
List<ClientProfile> profiles;
public Result(List<ClientProfile> profiles) {
this.profiles = profiles;
}
String requesttype = "profilesList";
String error;
}
}