feat: add initial classes for json package
This commit is contained in:
parent
034d046e39
commit
47fa16b9ee
25
src/com/uulm/marvelous/gamelibrary/json/JSON.java
Normal file
25
src/com/uulm/marvelous/gamelibrary/json/JSON.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.uulm.marvelous.gamelibrary.json;
|
||||||
|
|
||||||
|
import jdk.jshell.spi.ExecutionControl;
|
||||||
|
|
||||||
|
/** Contains JSON encoding and decoding.
|
||||||
|
*/
|
||||||
|
public class JSON {
|
||||||
|
/** Deserializes an incoming network message into a {@link MessageStructure}.
|
||||||
|
* @param input The JSON to deserialize.
|
||||||
|
* @return The parsed message.
|
||||||
|
*/
|
||||||
|
public static MessageStructure[] parse(String input) throws ExecutionControl.NotImplementedException {
|
||||||
|
//TODO: implement JSON.parse
|
||||||
|
throw new ExecutionControl.NotImplementedException("JSON.parse is not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Serializes a {@link MessageStructure} into a JSON string.
|
||||||
|
* @param input The message to serialize.
|
||||||
|
* @return The message as JSON.
|
||||||
|
*/
|
||||||
|
public static String stringify(MessageStructure input) throws ExecutionControl.NotImplementedException {
|
||||||
|
//TODO: implement JSON.stringify
|
||||||
|
throw new ExecutionControl.NotImplementedException("JSON.stringify is not implemented");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.uulm.marvelous.gamelibrary.json;
|
||||||
|
|
||||||
|
import com.uulm.marvelous.gamelibrary.events.Event;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/** Represents a message sent between client and server and contains all possible data.
|
||||||
|
*/
|
||||||
|
public class MessageStructure {
|
||||||
|
/** The list of {@link Event}s sent inside the message.
|
||||||
|
*/
|
||||||
|
public Event[] events;
|
||||||
|
|
||||||
|
/** The checksum of the current game state at the time the message was sent.
|
||||||
|
*/
|
||||||
|
public int checksum;
|
||||||
|
|
||||||
|
/** The type of the custom content sent with the message.
|
||||||
|
*/
|
||||||
|
public String customContentType;
|
||||||
|
|
||||||
|
/** The decoded contents of the custom content sent.
|
||||||
|
*/
|
||||||
|
public HashMap<String, Object> customContent;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user