103 lines
1.1 KiB
Markdown
103 lines
1.1 KiB
Markdown
# 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.
|