From b2fb6cc094fbf95624b635182351734c2c6231e6 Mon Sep 17 00:00:00 2001 From: Dennis Frieberg Date: Fri, 28 Aug 2020 20:58:43 +0200 Subject: [PATCH] reworked JSON format and wrote a bit more documentation --- Messages.json | 123 --------------------------------------- Messages.md | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+), 123 deletions(-) delete mode 100644 Messages.json create mode 100644 Messages.md diff --git a/Messages.json b/Messages.json deleted file mode 100644 index f62ed25..0000000 --- a/Messages.json +++ /dev/null @@ -1,123 +0,0 @@ -{ -"RequestType" : "SetPlayerTickR", -"RequestData" : { - "PlayerUUID" : null, - "PlayerName" : "PlayerName", - "PositionR" : { - "TickType" : "Tick", - "TickValue" : 0 - } - } -} - -{ -"RequestType" : "SetPlayerTickR", -"RequestData" : { - "PlayerUUID" : null, - "PlayerName" : "PlayerName", - "PositionR" : { - "TickType" : "Abwarten", - "TickValue" : null - } - } -} - -{ -"RequestType" : "SetPlayerTickR", -"RequestData" : { - "PlayerUUID" : null, - "PlayerName" : "PlayerName", - "PositionR" : { - "TickType" : "Bereithalten", - "TickValue" : null - } - } -} - -{ -"RequestType" : "SetPlayerTickR", -"RequestData" : { - "PlayerUUID" : 0, - "PositionR" : { - "TickType" : "Tick", - "TickValue" : 0 - } - } -} - -{ -"RequestType" : "SetPlayerTickR", -"RequestData" : { - "PlayerUUID" : 0, - "PositionR" : { - "TickType" : "Abwarten", - "TickValue" : null - } - } -} - -{ -"RequestType" : "SetPlayerTickR", -"RequestData" : { - "PlayerUUID" : 0, - "PositionR" : { - "TickType" : "Bereithalten", - "TickValue" : null - } - } -} - -{ -"RequestType" : "InitializeTickLeisteR", -} - -{ -"RequestType" : "TickLeisteR", -"RequestData" : { - "TickLeisteID" : 0 - } -} - -{ -"RequestType" : "ChangeNameR", -"RequestData" : { - "PlayerUUID" : 0, - "PlayerName" : "PlayerName" - } -} - - - - - -{ -"EventType" : "SetPlayerTickE", -"EventData" : { - "PlayerUUID" : 0, - "PlayerNameE" : "PlayerName", - "PositionE" : 0 - } -} - -{ -"EventType" : "InitializeTickLeisteE", -"EventData" : { - "TickLeisteID" : 0, - } -} - -{ -"EventType" : "TickLeisteE", -"EventData" : { - "TickLeisteID" : 0, - "TickLeisteData":[ - { - "PlayerUUID" : 0, - "PositionR" : { - "TickType" : "Tick", - "TickValue" : 0 - } - - }] - } -} \ No newline at end of file diff --git a/Messages.md b/Messages.md new file mode 100644 index 0000000..bd6b051 --- /dev/null +++ b/Messages.md @@ -0,0 +1,157 @@ +We will first describe some simple JSON values. We will use them later in more complicated +objects with the Syntax `"filedName" : `. We will write standard JSON types in the same +way. (For example `` for a correct JSON number). If there are multiple allowed values we will +write it with a `|`, for example `"fieldName" : |` if `"filedName"` may contain a +`` or a ``. + +For optional fields we write the corresponding value as ``. Optional fields +may contain `null` instead of their value type, or may be completely omitted. + +## DataTypes + +### Tuples +wi will write tuples types as `<(A,B)>` for a Tuple containing something of `A` and +something of `B`. We will encode this as a JSON Array of length n, where n is the +length of the tuple. +For example a Value of `<(Number,String)>` might be `[5,"Hello World!"]` + +### Lists +we will write `[A]` for the type of Lists containing stuff of type `A`. These are +encoded by Arrrays of arbitrary length. + +### Tick +#### TickType +A TickType is one of the following Strings: +`"Abwarten"`,`"Bereithalten"`,`"Tick"` +#### Tick +A Tick is an Object of the following form: +``` +{ +"TickType" : +"TickValue" : +} +``` +The TickValue field is only requiered if the "TickType" field contains the Value "Tick" + +### Player +#### UUID +we encode UUID as Strings of the following form: +"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +Where every x represents a character between 0 and f. + +#### Player +A Player is either an UnknownPlayer or a KnownPlayer. Aka `` +is a synonym for ` | `. As a client you +will never generate UUIDs for Player. This is always the job of the Server. + +##### KnownPlayer +``` +{ +"PlayerUUID" : +"PlayerName" : +} +``` + +If `"PlayerName"` is set, the Player has a new Name. The Server will always use KnownPlayer. If +you don't know that Player you should add it. + +##### UnknownPlayer +``` +{ +"PlayerUUID" : +"PlayerName" : +} +``` +Remark: `` allows you to optionaly include this field with a `null` value. But +you might omit it. + +UnknownPlayer are used to introduce new Player to the Server. + +### TickLeiste +As every Session has exactly one TickLeiste attached to it, we never need to communicate an ID +for a TickLeiste. But we still have to versions of TickLeiste. + +#### KnownTickLieste + +``` +[(,[])] +``` +These are mainly used to communicate existing TickLeisten from the server to the client + +#### UnknownTickLeiste +``` +[(,[])] +``` +These are mainly used so the client can initialize a TickLeiste. + +## Requests +a client is allowed to make the following Requests + +### RequestType +Every Request has a field `"RequestType" : `. For +the allowed values of `` and the implication for the rest of +the corresponding fields, look at the documentation of the specific requests. + +### SetPlayerTickR +This request is used to set a player to a specific Tick. If the Player is an +`UnknownPlayer` it will be added. +``` +{ +"RequestType" : "SetPlayerTickR", +"Player" : +"Tick" : +} +``` + +### InitializeTickLeisteR + +Initialize a new TickLeiste, either one saved on the client side, +to get a new empty one just set `"TickLeiste": []` + +``` +{ +"RequestType" : "InitializeTickLeisteR", +"TickLeiste" : +} +``` + +### TickLeisteR +Request the current TickLeiste +``` +{ +"RequestType" : "TickLeisteR", +} +``` +This is used to get the current TickLeiste from server. The server on its own will only +send incremental updates. + + +### ChangeNameR +This is used to change the name of a Player without moving them. +``` +{ +"RequestType" : "ChangeNameR", +"Player" : +} +``` +If you don't set the name in KnownPlayer no namechange will occur. + +## Events +A Server might Send the following Events to a client. + +### SetPlayerTickE +``` +{ +"EventType" : "SetPlayerTickE", +"Player" : +"Tick" : +} +``` + +### InitializeTickLeisteE +``` +{ +"EventType" : "InitializeTickLeisteE", +"TickLeiste" : +} +```