SuccessResult

This commit is contained in:
Gravit 2018-10-01 15:16:48 +07:00
parent 3daabe584f
commit df0d9f37a2
2 changed files with 15 additions and 5 deletions

View file

@ -32,7 +32,7 @@ public void sendObject(ChannelHandlerContext ctx, Object obj)
{
ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj)));
}
public class ErrorResult
public static class ErrorResult
{
public ErrorResult(String error) {
this.error = error;
@ -42,6 +42,16 @@ public ErrorResult(String error) {
public final String error;
public final String type;
}
public static class SuccessResult
{
public SuccessResult(String requesttype) {
this.requesttype = requesttype;
this.type = "success";
}
public final String requesttype;
public final String type;
}
public class ExceptionResult
{
public ExceptionResult(Exception e) {

View file

@ -67,15 +67,15 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx) throws
// throw new AuthException("You profile not found");
//}
server.config.hwidHandler.check(hwid, result.username);
service.sendObject(ctx,new WebSocketService.SuccessResult("auth"));
} catch (AuthException | HWIDException e)
{
service.sendObject(ctx,new ErrorResult(e.getMessage()));
service.sendObject(ctx,new WebSocketService.ErrorResult(e.getMessage()));
}
}
public class ErrorResult
public class Result
{
public ErrorResult(String error) {
this.error = error;
public Result() {
}
public String error;