[FEATURE] Портирован SetProfileResponse

This commit is contained in:
Gravit 2019-01-28 21:44:38 +07:00
parent 52609413a2
commit 751048ab3e
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 40 additions and 0 deletions

View file

@ -20,6 +20,7 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
if(!client.isAuth) if(!client.isAuth)
{ {
service.sendObject(ctx, new WebSocketService.ErrorResult("Access denied")); service.sendObject(ctx, new WebSocketService.ErrorResult("Access denied"));
return;
} }
service.sendObject(ctx, new Result((List<ClientProfile>) LaunchServer.server.getProfiles())); service.sendObject(ctx, new Result((List<ClientProfile>) LaunchServer.server.getProfiles()));
} }

View file

@ -0,0 +1,39 @@
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.Collection;
public class SetProfileResponse implements JsonResponseInterface {
@Override
public String getType() {
return "setProfile";
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
if(!client.isAuth)
{
service.sendObject(ctx, new WebSocketService.ErrorResult("Access denied"));
return;
}
Collection<ClientProfile> profiles = LaunchServer.server.getProfiles();
for (ClientProfile p : profiles) {
if (p.getTitle().equals(client)) {
if (!p.isWhitelistContains(client.username)) {
service.sendObject(ctx, new WebSocketService.ErrorResult(LaunchServer.server.config.whitelistRejectString));
return;
}
client.profile = p;
service.sendObject(ctx, new WebSocketService.SuccessResult(getType()));
break;
}
}
service.sendObject(ctx, new WebSocketService.ErrorResult("Profile not found"));
}
}