Skip to content

Commit

Permalink
docs: add summary of implementation and protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
thegamecracks committed Mar 9, 2024
1 parent 90b90ce commit cf4e25b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,45 @@ A handcrafted implementation of an internet relay chat without following
any conventions or RFC standards.

![Two client windows side-by-side](/docs/images/demo.png)

## Implementation

Dumdum consists of two parts:

1. The Sans-IO protocol, defined in [dumdum.protocol]
2. The asyncio wrapper, defined in [dumdum.client] and [dumdum.server]

The [Sans-IO] protocol is responsible for handling the generation and
consumption of byte streams, along with producing events from received
messages, while the asyncio wrapper is responsible for the actual network
communication between the server and its clients.

[Sans-IO]: https://sans-io.readthedocs.io/

[dumdum.protocol]: /src/dumdum/protocol/
[dumdum.client]: /src/dumdum/client/
[dumdum.server]: /src/dumdum/server.py

## Protocol

Clients are able to send the following messages:

1. AUTHENTICATE: `0x00 | 1-byte version | varchar nickname (32)`
2. SEND_MESSAGE: `0x01 | varchar channel name (32) | varchar content (1024)`
3. LIST_CHANNELS: `0x02`

Clients must send an AUTHENTICATE command before they can begin chat
communications.

Servers are able to send the following messages:

1. INCOMPATIBLE_VERSION: `0x00 | 1-byte version`
2. ACKNOWLEDGE_AUTHENTICATION: `0x01 | 0 or 1 success`
3. SEND_MESSAGE: `0x02 | varchar channel name (32) | varchar nickname (32) | varchar content (1024)`
4. LIST_CHANNELS: `0x03 | 2-byte length | varchar channel name (32) | ...`

When the client disconnects and reconnects, they MUST re-authenticate with the server.

As this protocol has been intentionally designed to be simple (no timeouts
or keep alives), I/O wrappers do not need a significant amount of work to
implement it.

0 comments on commit cf4e25b

Please sign in to comment.