Oh man that's a lot of changes.

This commit is contained in:
2026-02-28 15:59:03 -05:00
parent 226c4a8b52
commit de55288d37
11 changed files with 864 additions and 336 deletions

102
API.md Normal file
View File

@@ -0,0 +1,102 @@
# Overview
COMS uses a WebSocket API to communicate with its clients in JSON. In general,
packets sent to all clients end in `_evt` and packets sent in reply to a client
action end in `_ack`. Beyond that there isn't really a system.
A packet takes this general form:
```json
{
"type": "<PacketType>",
"data": {...}
}
```
# Data types
## Packet
**Type:**
```C
struct {
PacketType type;
Any data;
}
```
A packet.
## PacketType
**Type:**
```C
enum {
join,
welcome,
join_evt,
msg,
msg_evt,
name,
name_evt,
ping,
pong,
msg_ack,
name_ack,
leave_evt,
bad,
}
```
The type a Packet may assume.
## UserID
**Type:** `uint64_t`
Uniquely identifies a user.
## Name
**Type:** `char[16]`
A name of a user.
## UserData
**Type:**
```C
struct {
UserID id;
Name name;
}
```
A user.
## MsgID
**Type:** `uint64_t`
Uniquely identifies a message.
## MsgContent
**Type:** `char[1024]`
The content of a message.
## MsgData
**Type:**
```C
struct {
MsgID id;
UserData author;
MsgID parent;
MsgContent content;
time_t timestamp;
}
```
A message.