mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
docs(apis/websocket): update docs
This commit is contained in:
@@ -1,73 +1,73 @@
|
||||
<p align="center">
|
||||
<picture>
|
||||
<source
|
||||
width="256px"
|
||||
media="(prefers-color-scheme: dark)"
|
||||
srcset="../../assets/revanced-headline/revanced-headline-vertical-dark.svg"
|
||||
>
|
||||
<img
|
||||
width="256px"
|
||||
src="../../assets/revanced-headline/revanced-headline-vertical-light.svg"
|
||||
>
|
||||
</picture>
|
||||
<br>
|
||||
<a href="https://revanced.app/">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="../../assets/revanced-logo/revanced-logo-round.svg" />
|
||||
<img height="24px" src="../../assets/revanced-logo/revanced-logo-round.svg" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://github.com/ReVanced">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://i.ibb.co/dMMmCrW/Git-Hub-Mark.png" />
|
||||
<img height="24px" src="https://i.ibb.co/9wV3HGF/Git-Hub-Mark-Light.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="http://revanced.app/discord">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
|
||||
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://reddit.com/r/revancedapp">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
|
||||
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://t.me/app_revanced">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
|
||||
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://x.com/revancedapp">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/93124920/270180600-7c1b38bf-889b-4d68-bd5e-b9d86f91421a.png">
|
||||
<img height="24px" src="https://user-images.githubusercontent.com/93124920/270108715-d80743fa-b330-4809-b1e6-79fbdc60d09c.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://www.youtube.com/@ReVanced">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
|
||||
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<br>
|
||||
<br>
|
||||
Continuing the legacy of Vanced
|
||||
</p>
|
||||
|
||||
# 🚙 ReVanced Bot WebSocket API
|
||||
|
||||

|
||||
|
||||
The WebSocket API for ReVanced bots utilizing BSON for packet transmission with a heartbeating system to monitor the statuses of clients.
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
Documentation are provided [here](./docs/README.md).
|
||||
|
||||
## 📄 License
|
||||
|
||||
**ReVanced Bot WebSocket API** adopts the [GNU General Public License 3.0](./LICENSE), tl;dr: You may copy, distribute and modify the software as long as you track changes/dates in source files. Any modifications to or software including (via compiler) GPL-licensed code must also be made available under the GPL along with build & install instructions.
|
||||
<p align="center">
|
||||
<picture>
|
||||
<source
|
||||
width="256px"
|
||||
media="(prefers-color-scheme: dark)"
|
||||
srcset="../../assets/revanced-headline/revanced-headline-vertical-dark.svg"
|
||||
>
|
||||
<img
|
||||
width="256px"
|
||||
src="../../assets/revanced-headline/revanced-headline-vertical-light.svg"
|
||||
>
|
||||
</picture>
|
||||
<br>
|
||||
<a href="https://revanced.app/">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="../../assets/revanced-logo/revanced-logo-round.svg" />
|
||||
<img height="24px" src="../../assets/revanced-logo/revanced-logo-round.svg" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://github.com/ReVanced">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://i.ibb.co/dMMmCrW/Git-Hub-Mark.png" />
|
||||
<img height="24px" src="https://i.ibb.co/9wV3HGF/Git-Hub-Mark-Light.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="http://revanced.app/discord">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
|
||||
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://reddit.com/r/revancedapp">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
|
||||
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://t.me/app_revanced">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
|
||||
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://x.com/revancedapp">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/93124920/270180600-7c1b38bf-889b-4d68-bd5e-b9d86f91421a.png">
|
||||
<img height="24px" src="https://user-images.githubusercontent.com/93124920/270108715-d80743fa-b330-4809-b1e6-79fbdc60d09c.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<a href="https://www.youtube.com/@ReVanced">
|
||||
<picture>
|
||||
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
|
||||
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
|
||||
</picture>
|
||||
</a>
|
||||
<br>
|
||||
<br>
|
||||
Continuing the legacy of Vanced
|
||||
</p>
|
||||
|
||||
# 🚙 ReVanced Bot WebSocket API
|
||||
|
||||

|
||||
|
||||
The WebSocket API for ReVanced bots utilizing BSON for packet transmission with a heartbeating system to monitor the statuses of clients.
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
Documentation are provided [here](./docs/README.md).
|
||||
|
||||
## 📄 License
|
||||
|
||||
**ReVanced Bot WebSocket API** adopts the [GNU General Public License 3.0](./LICENSE), tl;dr: You may copy, distribute and modify the software as long as you track changes/dates in source files. Any modifications to or software including (via compiler) GPL-licensed code must also be made available under the GPL along with build & install instructions.
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
# 🏗️ Setting up the development environment
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **This project uses [Bun](https://bun.sh) to run and bundle the code.**
|
||||
> Compatibility with other runtimes (Node.js, Deno, ...) are not guaranteed and most package scripts won't work.
|
||||
|
||||
To start developing, you'll need to set up the development environment first.
|
||||
|
||||
1. Install [Bun](https://bun.sh)
|
||||
|
||||
2. Clone the mono-repository
|
||||
|
||||
```sh
|
||||
git clone https://github.com/ReVanced/revanced-helper.git &&
|
||||
cd revanced-helper
|
||||
```
|
||||
|
||||
3. Install dependencies
|
||||
|
||||
```sh
|
||||
bun install
|
||||
```
|
||||
|
||||
4. Build packages/libraries
|
||||
|
||||
```sh
|
||||
bun build:libs
|
||||
```
|
||||
|
||||
5. Change your directory to this project's root
|
||||
```sh
|
||||
cd apis/websocket
|
||||
```
|
||||
|
||||
## ⏭️ What's next
|
||||
|
||||
The next page will tell you about server configurations.
|
||||
|
||||
Continue: [⚙️ Configuration](./1_configuration.md)
|
||||
# 🏗️ Setting up the development environment
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **This project uses [Bun](https://bun.sh) to run and bundle the code.**
|
||||
> Compatibility with other runtimes (Node.js, Deno, ...) are not guaranteed and most package scripts won't work.
|
||||
|
||||
To start developing, you'll need to set up the development environment first.
|
||||
|
||||
1. Install [Bun](https://bun.sh)
|
||||
|
||||
2. Clone the mono-repository
|
||||
|
||||
```sh
|
||||
git clone https://github.com/ReVanced/revanced-helper.git &&
|
||||
cd revanced-helper
|
||||
```
|
||||
|
||||
3. Install dependencies
|
||||
|
||||
```sh
|
||||
bun install
|
||||
```
|
||||
|
||||
4. Build packages/libraries
|
||||
|
||||
```sh
|
||||
bun build:libs
|
||||
```
|
||||
|
||||
5. Change your directory to this project's root
|
||||
```sh
|
||||
cd apis/websocket
|
||||
```
|
||||
|
||||
## ⏭️ What's next
|
||||
|
||||
The next page will tell you about server configurations.
|
||||
|
||||
Continue: [⚙️ Configuration](./1_configuration.md)
|
||||
|
||||
@@ -1,48 +1,49 @@
|
||||
# ⚙️ Configuration
|
||||
|
||||
This is the default configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"address": "127.0.0.1",
|
||||
"port": 3000,
|
||||
"ocrConcurrentQueues": 1,
|
||||
"clientHeartbeatInterval": 60000,
|
||||
"debugLogsInProduction": false
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `config.address` & `config.port`
|
||||
|
||||
The address and port for the server to listen on.
|
||||
|
||||
### `config.ocrConcurrentQueues`
|
||||
|
||||
Amount of concurrent queues that can be run at a time.
|
||||
|
||||
> Setting this too high may cause performance issues.
|
||||
|
||||
### `config.clientHeartbeatInterval`
|
||||
|
||||
Heartbeat interval for clients. See [**💓 Heartbeating**](./packets.md#💓-heartbeating).
|
||||
|
||||
### `config.consoleLogLevel`
|
||||
|
||||
The level of logs to print to console. If the level is more important or equally important to set level, it will be forwarded to the console.
|
||||
|
||||
The possible levels (sorted by their importance descendingly) are:
|
||||
- `fatal`
|
||||
- `error`
|
||||
- `warn`
|
||||
- `info`
|
||||
- `log`
|
||||
- `trace`
|
||||
- `debug`
|
||||
|
||||
## ⏭️ What's next
|
||||
|
||||
The next page will tell you how to run and bundle the server.
|
||||
|
||||
Continue: [🏃🏻♂️ Running the server](./2_running.md)
|
||||
# ⚙️ Configuration
|
||||
|
||||
This is the default configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"address": "127.0.0.1",
|
||||
"port": 3000,
|
||||
"ocrConcurrentQueues": 1,
|
||||
"clientHeartbeatInterval": 60000,
|
||||
"debugLogsInProduction": false
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `config.address` & `config.port`
|
||||
|
||||
The address and port for the server to listen on.
|
||||
|
||||
### `config.ocrConcurrentQueues`
|
||||
|
||||
Amount of concurrent queues that can be run at a time.
|
||||
|
||||
> Setting this too high may cause performance issues.
|
||||
|
||||
### `config.clientHeartbeatInterval`
|
||||
|
||||
Heartbeat interval for clients. See [**💓 Heartbeating**](./packets.md#💓-heartbeating).
|
||||
|
||||
### `config.consoleLogLevel`
|
||||
|
||||
The level of logs to print to console. If the level is more important or equally important to set level, it will be forwarded to the console.
|
||||
|
||||
The possible levels (sorted by their importance descendingly) are:
|
||||
|
||||
- `fatal`
|
||||
- `error`
|
||||
- `warn`
|
||||
- `info`
|
||||
- `log`
|
||||
- `trace`
|
||||
- `debug`
|
||||
|
||||
## ⏭️ What's next
|
||||
|
||||
The next page will tell you how to run and bundle the server.
|
||||
|
||||
Continue: [🏃🏻♂️ Running the server](./2_running.md)
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
# 🏃🏻♂️ Running the server
|
||||
|
||||
There are many methods to run the server. Choose one that suits best for the situation.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Make sure you've followed the [**🏗️ Setting up the environment**](./0_development_environment.md) steps.
|
||||
|
||||
## 👷🏻 Development mode (recommended)
|
||||
|
||||
There will be no compilation step, and Bun will automatically watch changes and restart the server for you.
|
||||
|
||||
You can quickly start the server by running:
|
||||
|
||||
```sh
|
||||
bun dev
|
||||
```
|
||||
|
||||
## 🌐 Production mode
|
||||
|
||||
Production mode runs no different from the development server, it simply has less debugging information printed to console by default. However, more production-specific features may come.
|
||||
|
||||
To start the server in production mode, you'll have to:
|
||||
|
||||
1. Set the `NODE_ENV` environment variable to `production`
|
||||
|
||||
> It is very possible to set the value in the `.env` file and let Bun load it, **but it is recommended to set the variable before Bun even starts**.
|
||||
|
||||
2. Start the server
|
||||
```sh
|
||||
bun dev
|
||||
```
|
||||
|
||||
## 📦 Building
|
||||
|
||||
If you're looking to build and host the server somewhere else, you can run:
|
||||
|
||||
```sh
|
||||
bun bundle
|
||||
```
|
||||
|
||||
The files will be placed in the `dist` directory. **Configurations and `.env` files will NOT be copied automatically.**
|
||||
# 🏃🏻♂️ Running the server
|
||||
|
||||
There are many methods to run the server. Choose one that suits best for the situation.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Make sure you've followed the [**🏗️ Setting up the environment**](./0_development_environment.md) steps.
|
||||
|
||||
## 👷🏻 Development mode (recommended)
|
||||
|
||||
There will be no compilation step, and Bun will automatically watch changes and restart the server for you.
|
||||
|
||||
You can quickly start the server by running:
|
||||
|
||||
```sh
|
||||
bun dev
|
||||
```
|
||||
|
||||
## 🌐 Production mode
|
||||
|
||||
Production mode runs no different from the development server, it simply has less debugging information printed to console by default. However, more production-specific features may come.
|
||||
|
||||
To start the server in production mode, you'll have to:
|
||||
|
||||
1. Set the `NODE_ENV` environment variable to `production`
|
||||
|
||||
> It is very possible to set the value in the `.env` file and let Bun load it, **but it is recommended to set the variable before Bun even starts**.
|
||||
|
||||
2. Start the server
|
||||
```sh
|
||||
bun dev
|
||||
```
|
||||
|
||||
## 📦 Building
|
||||
|
||||
If you're looking to build and host the server somewhere else, you can run:
|
||||
|
||||
```sh
|
||||
bun bundle
|
||||
```
|
||||
|
||||
The files will be placed in the `dist` directory. **Configurations and `.env` files will NOT be copied automatically.**
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
# 📨 Packets
|
||||
|
||||
Packets are BSON messages sent to the server. They're structured like the following when decoded:
|
||||
|
||||
```json
|
||||
{
|
||||
"op": 12345,
|
||||
"d": {
|
||||
"some_field": "some data"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `packet.op`
|
||||
|
||||
Operation codes are numbers that communicate an action.
|
||||
|
||||
### `packet.d`
|
||||
|
||||
Data fields include additional information for the server to process. They are **either an object with specific fields or just `null`**.
|
||||
|
||||
#### 📦 Schemas and constants
|
||||
|
||||
Schemas for packets and their respective data[^1], and the list of possible operation codes[^2] can be found in the `@revanced/bot-shared` package, with typings as well.
|
||||
|
||||
[^1]: [`@revanced/bot-shared/src/schemas/Packet.ts`](../../packages/shared/src/schemas/Packet.ts)
|
||||
[^2]: [`@revanced/bot-shared/src/constants/Operation`](../../packages/shared/src/constants/Operation.ts)
|
||||
|
||||
## 💓 Heartbeating
|
||||
|
||||
Heartbeating is a process where the client regularly send each other signals to confirm that they are still connected and functioning. If the server doesn't receive a heartbeat from the client within a specified timeframe, it assume the client has disconnected and closes the socket.
|
||||
|
||||
You can configure the interval in the configuration file. See [**📝 Configuration > `config.clientHeartbeatInterval`**](./1_configuration.md#configclientheartbeatinterval).
|
||||
# 📨 Packets
|
||||
|
||||
Packets are BSON messages sent to the server. They're structured like the following when decoded:
|
||||
|
||||
```json
|
||||
{
|
||||
"op": 12345,
|
||||
"d": {
|
||||
"some_field": "some data"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `packet.op`
|
||||
|
||||
Operation codes are numbers that communicate an action.
|
||||
|
||||
### `packet.d`
|
||||
|
||||
Data fields include additional information for the server to process. They are **either an object with specific fields or just `null`**.
|
||||
|
||||
#### 📦 Schemas and constants
|
||||
|
||||
Schemas for packets and their respective data[^1], and the list of possible operation codes[^2] can be found in the `@revanced/bot-shared` package, with typings as well.
|
||||
|
||||
[^1]: [`@revanced/bot-shared/src/schemas/Packet.ts`](../../packages/shared/src/schemas/Packet.ts)
|
||||
[^2]: [`@revanced/bot-shared/src/constants/Operation`](../../packages/shared/src/constants/Operation.ts)
|
||||
|
||||
## 💓 Heartbeating
|
||||
|
||||
Heartbeating is a process where the client regularly send each other signals to confirm that they are still connected and functioning. If the server doesn't receive a heartbeat from the client within a specified timeframe, it assume the client has disconnected and closes the socket.
|
||||
|
||||
You can configure the interval in the configuration file. See [**📝 Configuration > `config.clientHeartbeatInterval`**](./1_configuration.md#configclientheartbeatinterval).
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# 🚙 ReVanced Bot WebSocket API
|
||||
|
||||
This documentation explains how the server works, how to start developing, and how to configure the server.
|
||||
|
||||
## 📖 Table of contents
|
||||
|
||||
0. [🏗️ Setting up the development environment](./0_development_environment.md)
|
||||
1. [⚙️ Configuration](./1_configuration.md)
|
||||
2. [🏃🏻♂️ Running the server](./2_running.md)
|
||||
3. [📨 Packets](./3_packets.md)
|
||||
|
||||
## ⏭️ Start here
|
||||
|
||||
The next page will tell you how to set up the development environment.
|
||||
|
||||
Continue: [🏗️ Setting up the development environment](./0_development_environment.md)
|
||||
# 🚙 ReVanced Bot WebSocket API
|
||||
|
||||
This documentation explains how the server works, how to start developing, and how to configure the server.
|
||||
|
||||
## 📖 Table of contents
|
||||
|
||||
0. [🏗️ Setting up the development environment](./0_development_environment.md)
|
||||
1. [⚙️ Configuration](./1_configuration.md)
|
||||
2. [🏃🏻♂️ Running the server](./2_running.md)
|
||||
3. [📨 Packets](./3_packets.md)
|
||||
|
||||
## ⏭️ Start here
|
||||
|
||||
The next page will tell you how to set up the development environment.
|
||||
|
||||
Continue: [🏗️ Setting up the development environment](./0_development_environment.md)
|
||||
|
||||
Reference in New Issue
Block a user