Skip to content

Commit cd120da

Browse files
authored
Add documentation for CloudLink 3 protocol
Document the CloudLink 3 protocol specifications, including client-to-server and server-to-client schemas with detailed command descriptions.
1 parent 00d47c3 commit cd120da

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

cl3.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# CloudLink 3 ("CL3") Protocol
2+
3+
CloudLink 3 was a critical transitional phase for the protocol. It marked the complete shift away from the legacy multi-line string format (CL2) to a more modern, fully JSON-based system. While it laid the groundwork for CL4, it remained a straightforward, polling-based client-server protocol and did not include advanced features like rooms or listeners.
4+
5+
## Client-to-Server Schema
6+
7+
All communication from a CL3 client to the server is a single JSON object. The structure is simpler than CL4, with some commands requiring an `origin` key.
8+
9+
```js
10+
{
11+
"cmd": "...",
12+
"val": "...",
13+
"name": "...",
14+
"id": "...",
15+
"origin": "..."
16+
}
17+
```
18+
19+
`cmd` is the command, `val` is the payload, `name` is for variables, `id` specifies a recipient, and `origin` is used to identify the sender in private messages.
20+
21+
| `opcode` | Description | Dialect Notes |
22+
| :--- | :--- | :--- |
23+
| **`setid`** | Sets the client's username. The `val` key contains the username. | Consistent across all CL3 dialects. |
24+
| **`direct`** | A command for direct server interaction. Used by clients to identify their type. | **v0.1.7**: The client sends a payload of `{"cmd": "type", "val": "scratch"}` upon connection to identify itself. |
25+
| **`gmsg`** | A global message sent to all clients. The `val` key contains the data payload. | Consistent across all CL3 dialects. |
26+
| **`pmsg`** | A private message. `val` is the data, `id` is the recipient, and `origin` is the sender's username. | Consistent across all CL3 dialects. |
27+
| **`gvar`** / **`pvar`** | A variable sync message. `name` specifies the variable name, and `val` is its new value. `pvar` also requires `id` and `origin`. | Consistent across all CL3 dialects. |
28+
29+
## Server-to-Client Schema
30+
31+
Server responses are also JSON objects, but the structure can be less consistent than in CL4. Metadata is often nested within a `direct` command.
32+
33+
```js
34+
{
35+
"cmd": "...",
36+
"val": "...",
37+
"name": "...",
38+
"origin": "..."
39+
}
40+
```
41+
42+
| `opcode` | Description | Dialect Notes |
43+
| :--- | :--- | :--- |
44+
| **`gmsg`** / **`pmsg`** | A global or private message payload. | Consistent across all CL3 dialects. |
45+
| **`gvar`** / **`pvar`** | A variable update. `name` specifies the variable, `val` is its new value. | Consistent across all CL3 dialects. |
46+
| **`ulist`** | The list of connected users. The `val` is a single string with usernames separated by semicolons (e.g., `"UserA;UserB;"`). | This string-based format is a key characteristic of CL3 and earlier protocols. |
47+
| **`direct`** | A command used by the server to send metadata to the client. The `val` is a nested object containing a subcommand (`vers`, `motd`) and its value. | **v0.1.7**: This is the primary method for sending the server version (`vers`) and Message of the Day (`motd`).<br>**v0.1.5**: Does not support receiving `motd`. |
48+
| **`statuscode`** | A status message from the server, often in response to a command like `setid`. | Support for receiving status codes begins with dialect **v0.1.7**. |
49+
| **`ds`** | A command sent from the server to indicate it is shutting down, instructing the client to disconnect. | Consistent across all CL3 dialects. |

0 commit comments

Comments
 (0)