wschat
is very simple WebSocket chat server. The project is published
under AGPLv3 License.
When a WebSocket is opened, the server expects the following 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"
}
And sends the message to all the opened WebSockets (including the sending one.)
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"
}
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
field exp
.
See static
directory to check out a simple wschat
client example.
Use OneFlow branching model and keep the changelog.
Write great git commit messages:
When adding feature or hotfix, use Test-driven development (TDD):
cargo test
), check that the test fail.Document new functions, methods, structs, and files. Use Examples section as basic unit tests.