This repository was archived by the owner on Apr 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
The CloudLink Protocol
Mike J. Renaker / "MikeDEV edited this page Apr 4, 2023
·
4 revisions
Work in progress!
This page outlines CLPv4.1. Packets within CLPv4.1 are compliant with UPLv2.2.
UPLv2.2 is a formatting scheme that simplifies the protocol, and has existed since CLPv3.
In short, each packet that is UPL compliant is a JSON encoded text frame.
Each JSON message will have no more than these root keys:
{
"cmd": String, // Required for all commands, The CL Protocol command to execute.
"val": [ // Command-specific. Not required for some commands.
String,
Integer,
Boolean,
Object, // Dictionary in Python terms
Float
],
"mode": String, // Only used for server to client ulist command
"name": String, // Required for variable-related commands.
"id": String, // Required for direct or private message commands.
"relay": String, // Optional, same as id, but will relay the entire packet instead. UPLv2.2 specific.
"listener": String // Optional, attach to message to get a response.
"rooms": [ // Optional for client to server messages, required for server to client messages if a client is linked to rooms
String,
List // List of strings
]
}
When a client connects to a CloudLink server, it is recommended that the first message to be sent client to server is the handshake
command.
Request
{
"cmd": "handshake",
"listener": String // Optional
}
Responses
- The server will return the detected IP address of the client.
{
"cmd": "client_ip",
"val": String
}
- The server will report what version it's running.
{
"cmd": "server_version",
"val": String
}
- If enabled, the server will provide its "Message of the Day".
{
"cmd": "motd",
"val": String
}
- The server will provide the client it's user object info.
{
"cmd": "client_obj",
"val": {
"id": String, // Snowflake ID
"uuid": String // UUID
}
}
- The server will report the current userlist of the
default
room.
{
"cmd": "ulist",
"mode": "set",
"val": [], // List of user objects, following the same format as client_obj
"rooms": "default"
}
- The server will return a status code (and a listener, if specified).
{
"cmd": "statuscode",
"code": "I:100 | OK",
"code_id": 100,
"listener": String
}
Afterwards, the client does not need to send the handshake
command during the remainder of the websocket connection.
Before you can utilize link
, unlink
, pmsg
, pvar
, direct
, or relay
commands, you will need to set a username for your client.
Request
{
"cmd": "setid",
"val": String // Username
}
Response
- The server will broadcast a
ulist add
command to other clients. This message does not get sent to your client.
{
"cmd": "ulist",
"mode": "add",
"val": {
"id": String, // Your Snowflake ID
"username": String, // Your Username
"uuid": String // Your UUID
},
"rooms": "default"
}
- The server will return to you with a
ulist set
command.
{
"cmd": "ulist",
"mode": "set",
"val": [] // List of user objects, which will include your updated user object
"rooms": "default"
}
- The server will return a status code (and a listener, if specified).
{
"cmd": "statuscode",
"code": "I:100 | OK",
"code_id": 100,
"listener": String
}