Skip to content
This repository was archived by the owner on Dec 23, 2022. It is now read-only.

Commit f068af2

Browse files
committed
Added websocket api definition
1 parent c1a40ed commit f068af2

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

docs/protocol/websocket.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Websocket Api
2+
3+
The websocket api is the interface for any frontend to communicate with the backend.
4+
<br>
5+
By default the websocket is available at `/ws`. (e.g. `wss://server.cryptic-game.net/ws`)
6+
7+
## Request
8+
9+
```json
10+
{
11+
"tag": "random string",
12+
"endpoint": "user/register",
13+
"data": {
14+
"username": "TestUser",
15+
"password": "#Test123"
16+
}
17+
}
18+
```
19+
20+
| Name | Description |
21+
|------------|----------------------------------------------------------------------------------------------------------------|
22+
| `tag` | The tag is a random string witch is copied to the response of this request to identify the according response. |
23+
| `endpoint` | The endpoint witch should be executed. |
24+
| `data` | The data witch should be passed to the endpoint. |
25+
26+
## Response
27+
28+
```json
29+
{
30+
"status": {
31+
"code": 200,
32+
"name": "OK"
33+
},
34+
"error": "<message>", // optional
35+
"tag": "random string",
36+
"data": {
37+
"id": "fd973bf5-3801-402f-8c85-d5313aa02baa",
38+
"user_id": "2cea82a0-3425-4d0e-8e1b-4823ad744162"
39+
}
40+
}
41+
```
42+
43+
| Name | Description |
44+
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
45+
| `status` | The status code and name of the response. The codes are similar to the [Http Status Codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status). |
46+
| `error` | A optional error message. |
47+
| `tag` | The same value as in the request. |
48+
| `data` | A optional data witch the endpoint produced. |
49+
50+
## Notification
51+
52+
```json
53+
{
54+
"status": {
55+
"code": 900,
56+
"name": "Notification"
57+
},
58+
"topic": "MESSAGE_SEND",
59+
"data": {
60+
"user_id": "fd973bf5-3801-402f-8c85-d5313aa02baa",
61+
"whisper": false,
62+
"content": "Hello"
63+
}
64+
}
65+
```
66+
67+
| Name | Description |
68+
|----------|--------------------------------------------------------------------|
69+
| `status` | The status is in every Notification the same. |
70+
| `topic` | The topic of the notification. It can be interpreted as a channel. |
71+
| `data` | A optional data of the notification. |

mkdocs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ extra:
4444
link: https://github.com/cryptic-game
4545
- icon: fontawesome/brands/twitter
4646
link: https://twitter.com/Cryptic_Game
47+
48+
markdown_extensions:
49+
- pymdownx.highlight:
50+
linenums: true
51+
- pymdownx.superfences

0 commit comments

Comments
 (0)