CLI Client #15
This commit is contained in:
@@ -3,7 +3,7 @@ package eu.jonahbauer.wizard.common.messages.client;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
import eu.jonahbauer.wizard.common.messages.observer.ObserverMessage;
|
||||
import eu.jonahbauer.wizard.common.messages.player.PlayerMessage;
|
||||
import eu.jonahbauer.wizard.common.util.SealedClassTypeAdapterFactory;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
|
||||
public abstract sealed class ClientMessage permits CreateSessionMessage, InteractionMessage, JoinSessionMessage, LeaveSessionMessage, ReadyMessage, RejoinMessage {
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.registerTypeAdapterFactory(SealedClassTypeAdapterFactory.of(ClientMessage.class, "Message"))
|
||||
.registerTypeAdapterFactory(SealedClassTypeAdapterFactory.of(ObserverMessage.class, "Message"))
|
||||
.registerTypeAdapterFactory(SealedClassTypeAdapterFactory.of(PlayerMessage.class, "Message"))
|
||||
.create();
|
||||
|
||||
public static ClientMessage parse(String json) throws JsonParseException {
|
||||
|
@@ -3,12 +3,14 @@ package eu.jonahbauer.wizard.common.messages.data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode(of = "uuid")
|
||||
@ToString
|
||||
public class PlayerData {
|
||||
/**
|
||||
* UUID of the player
|
||||
|
@@ -4,12 +4,14 @@ import eu.jonahbauer.wizard.common.model.Configuration;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode(of = "uuid")
|
||||
@ToString
|
||||
public class SessionData {
|
||||
/**
|
||||
* UUID of the session
|
||||
|
@@ -7,8 +7,19 @@ import org.intellij.lang.annotations.MagicConstant;
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class NackMessage extends ServerMessage implements Response {
|
||||
public static final int BAD_REQUEST = 400;
|
||||
public static final int NOT_FOUND = 404;
|
||||
public static final int MALFORMED_MESSAGE = 100;
|
||||
public static final int UNEXPECTED_MESSAGE = 101;
|
||||
|
||||
public static final int ILLEGAL_ARGUMENT = 200;
|
||||
public static final int NAME_TAKEN = 201;
|
||||
public static final int NOT_FOUND = 210;
|
||||
public static final int SESSION_NOT_FOUND = 211;
|
||||
public static final int PLAYER_NOT_FOUND = 212;
|
||||
|
||||
public static final int ILLEGAL_STATE = 300;
|
||||
public static final int GAME_ALREADY_STARTED = 301;
|
||||
public static final int GAME_NOT_YET_STARTED = 302;
|
||||
public static final int SESSION_FULL = 303;
|
||||
|
||||
private final int code;
|
||||
private final String message;
|
||||
|
Reference in New Issue
Block a user