@@ 11,22 11,21 @@ under [AGPLv3 License][].
Messaging
=========
-When a WebSocket is opened, the server expects the following JSON message:
-```
-{
- "usr": "Chat user",
- "msg": "Message from that user"
-}
-```
+When a WebSocket is opened, the server expects (at least) the following fields
+in a JSON message:
+
+ {
+ "usr": "Chat user",
+ "msg": "Message from that user"
+ }
Then, the server updates the message with current UTC date/time:
-```
-{
- "usr": "Chat user",
- "msg": "Message from that user",
- "tim": "2020-08-11T22:26:58.118678679Z"
-}
-```
+
+ {
+ "usr": "Chat user",
+ "msg": "Message from that user",
+ "tim": "2020-08-11T22:26:58.118678679Z"
+ }
And sends the message to all the opened WebSockets (including the sending one.)
@@ 35,13 34,12 @@ JWT validation
If the server is run with `JWT_SECRET` environment variable, it expects another
field in the JSON message:
-```
-{
- "usr": "Chat user",
- "jwt": "Encoded JWT here",
- "msg": "Message from that user"
-}
-```
+
+ {
+ "usr": "Chat user",
+ "jwt": "Encoded JWT here",
+ "msg": "Message from that user"
+ }
Then, the server decode each message with `JWT_SECRET` and sends the message
only if the docode is successful. This validation does not concern expiration