simworld/doc/DESIGN.gmi

52 lines
1.4 KiB
Plaintext
Raw Normal View History

# DESIGN
This document describes the design of this project. The main purpose is to describe the interface between the client and the server, but I might document other useful information here, too.
## Client/Server Communication
All communication is done through JSON.
### Client Requests
Clients can make requests to the server by sending a JSON object containing two fields:
* "request", which is a string of name of the request being made
* "parameters", which is an object whose structure depends on the request. It contains a named list of the request's parameters
### Server Responses
Upon receiving and handling a request, the server will send a response object with the following fields:
* "success", a boolean that indicates whether the request succeeded
* "response", an object whose structure depends on the request. It contains data relevant to the request
### Example Request and Response
An example request might look as follows:
```
{
"request": "create-world",
"parameters": {
"name": "test world",
"size": {
"height": 10,
"width": 15,
}
}
}
```
A success response might look like:
```
{
"success": true,
"response": {
"world-id": 69420
}
}
```
Or, in the case of an error:
```
{
"success": false,
"response": {
"code": 69
"message": "A world with this name already exists"
}
}
```