2.0 KiB
2.0 KiB
Spec v2
What does it entail?
- The client
- The client connects to the server and sends commands to it.
- The server
- The server receives commands from the client and dispatches them to the respective message handler, waits for a reply and then either sends the reply to a client (originator or otherwise) or another server.
- The message handler
- Receives commands from the client indirectly (via the server), processes them and then sends a response back to the server (as implied above, who the reply is sent to is decided by the message handler and the server will act accordingly)
Flow
Client
Describes client-to-server and server-to-client communications.
Client -> Server
If a client wants to send a command through to the server then the following bytes must be sent:
[ 4 bytes (size - little endian)][JSON message]
The [JSON message]
contains information that the server will
use to gain the following information:
* Authentication: Is the user allowed to use this server?
* Type: Which message handler should be responsible for
processing this message.
* Payload: The data to be processed by the message handler.
The structure of the [JSON message]
is as follows:
{
"header" : {
"authentication" : {
"username" : "username",
"password" : "password"
}
},
"payload" : {
"type" : "type",
"data" : ...
}
}
- The
[JSON message]
MUST contain two fields,header
andpayload
which MUST be JSON objects. - The
header
field MUST contain a field namedauthentication
which MUST be a JSON object and must contain two fields,username
andpassword
, which MUST be JSON strings. - The
[JSON message]
MUST contain a field namedpayload
which MUST be a JSON object and MUST contain two fields,type
anddata
, wheretype
MUST be a JSON string anddata
can be any JSON type.
TODO
Client <- Server
TODO: But basically anything can go here as it is all in order so you will get your reply.