feat!: big feature changes

BREAKING CHANGES:
- Heartbeating removed
- `config.consoleLogLevel` -> `config.logLevel`

NEW FEATURES:
- Training messages
- Sequence number system
- WebSocket close codes used instead of disconnect packets

FIXES:
- Improved error handling
- Some performance improvements
- Made code more clean
- Updated dependencies
This commit is contained in:
PalmDevs
2024-03-28 21:41:59 +07:00
parent 77f1a9cb3e
commit b3b7723b4f
33 changed files with 562 additions and 506 deletions

View File

@@ -7,7 +7,6 @@ This is the default configuration (provided in [config.json](../config.json)):
"address": "127.0.0.1",
"port": 3000,
"ocrConcurrentQueues": 1,
"clientHeartbeatInterval": 60000,
"consoleLogLevel": "log"
}
```
@@ -25,22 +24,18 @@ Amount of concurrent queues that can be run at a time.
> [!WARNING]
> Setting this too high may cause performance issues.
### `config.clientHeartbeatInterval`
Heartbeat interval for clients. See [**💓 Heartbeating**](./3_packets.md#💓-heartbeating).
### `config.consoleLogLevel`
### `config.logLevel`
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:
- `none` (no messages)
- `fatal`
- `error`
- `warn`
- `info`
- `log`
- `trace`
- `debug`
## ⏭️ What's next

View File

@@ -36,7 +36,7 @@ bun bundle
```
The files will be placed in the `dist` directory. **Configurations and `.env` files will NOT be copied automatically.**
You can run these files after using a runtime, eg. `bun run .` or `node .`.
You can run these files using the command `bun run index.js`.
## ⏭️ What's next

View File

@@ -19,15 +19,13 @@ Operation codes are numbers that communicate an action.
Data fields include additional information for the server to process. They are **either an object with specific fields or just `null`**.
### `packet.s` (server packets)
A sequence number, exclusively for server packets. The WebSocket server contacts other APIs and they may not be reliable at all times, this makes race conditions. A sequence number cleanly solves this issue by letting the client know what the next packet sequence number would be by giving the current number.
#### 📦 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).