mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-26 04:31:03 +00:00
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:
@@ -3,29 +3,33 @@
|
||||
*/
|
||||
enum DisconnectReason {
|
||||
/**
|
||||
* Unknown reason
|
||||
* The client disconnected on its own (**CLIENT-ONLY**)
|
||||
*/
|
||||
Generic = 1,
|
||||
/**
|
||||
* The client did not respond in time
|
||||
*/
|
||||
TimedOut = 2,
|
||||
PlannedDisconnect = 1000,
|
||||
/**
|
||||
* The client sent an invalid packet (unserializable or invalid JSON)
|
||||
*/
|
||||
InvalidPacket = 3,
|
||||
InvalidPacket = 1007,
|
||||
/**
|
||||
* The server has encountered an internal error
|
||||
*/
|
||||
ServerError = 4,
|
||||
ServerError = 1011,
|
||||
/**
|
||||
* The client had never connected to the server (**CLIENT-ONLY**)
|
||||
* Unknown reason
|
||||
*/
|
||||
NeverConnected = 5,
|
||||
Generic = 4000,
|
||||
/**
|
||||
* The client disconnected on its own (**CLIENT-ONLY**)
|
||||
* The client did not respond with a heartbeat in time
|
||||
*/
|
||||
PlannedDisconnect = 6,
|
||||
TimedOut = 4001,
|
||||
/**
|
||||
* The receiving end didn't have an open socket
|
||||
*/
|
||||
NoOpenSocket = 4003,
|
||||
/**
|
||||
* The client was not ready in time (**CLIENT-ONLY**)
|
||||
*/
|
||||
TooSlow = 4002,
|
||||
}
|
||||
|
||||
export default DisconnectReason
|
||||
|
||||
@@ -4,12 +4,14 @@ import DisconnectReason from './DisconnectReason'
|
||||
* Humanized disconnect reasons for logs
|
||||
*/
|
||||
const HumanizedDisconnectReason = {
|
||||
[DisconnectReason.InvalidPacket]: 'has sent invalid packet',
|
||||
[DisconnectReason.Generic]: 'has been disconnected for unknown reasons',
|
||||
[DisconnectReason.TimedOut]: 'has timed out',
|
||||
[DisconnectReason.ServerError]: 'has been disconnected due to an internal server error',
|
||||
[DisconnectReason.NeverConnected]: 'had never connected to the server',
|
||||
[DisconnectReason.PlannedDisconnect]: 'has disconnected on its own',
|
||||
} as const satisfies Record<DisconnectReason, string>
|
||||
[1006]: 'the receiving end had unexpectedly closed the connection',
|
||||
[DisconnectReason.InvalidPacket]: 'the client has sent invalid packet',
|
||||
[DisconnectReason.Generic]: '(unknown reason)',
|
||||
[DisconnectReason.TimedOut]: 'the client did not respond with a heartbeat in time',
|
||||
[DisconnectReason.ServerError]: 'the server had an internal server error',
|
||||
[DisconnectReason.TooSlow]: 'the client was not ready in time',
|
||||
[DisconnectReason.PlannedDisconnect]: 'the client has disconnected on its own',
|
||||
[DisconnectReason.NoOpenSocket]: 'the receiving end did not have an open socket',
|
||||
} as const satisfies Record<DisconnectReason | number, string>
|
||||
|
||||
export default HumanizedDisconnectReason
|
||||
|
||||
@@ -2,33 +2,28 @@
|
||||
* Client operation codes for the gateway
|
||||
*/
|
||||
export enum ClientOperation {
|
||||
/**
|
||||
* Client's heartbeat (to check if the connection is dead or not)
|
||||
*/
|
||||
Heartbeat = 100,
|
||||
|
||||
/**
|
||||
* Client's request to parse text
|
||||
*/
|
||||
ParseText = 110,
|
||||
ParseText = 100,
|
||||
/**
|
||||
* Client's request to parse image
|
||||
*/
|
||||
ParseImage = 111,
|
||||
ParseImage = 101,
|
||||
/**
|
||||
* Client's request to train a message
|
||||
*/
|
||||
TrainMessage = 102,
|
||||
}
|
||||
|
||||
/**
|
||||
* Server operation codes for the gateway
|
||||
*/
|
||||
export enum ServerOperation {
|
||||
/**
|
||||
* Server's acknowledgement of a client's heartbeat
|
||||
*/
|
||||
HeartbeatAck = 1,
|
||||
/**
|
||||
* Server's initial response to a client's connection
|
||||
*/
|
||||
Hello = 2,
|
||||
Hello = 1,
|
||||
|
||||
/**
|
||||
* Server's response to client's request to parse text
|
||||
@@ -46,6 +41,14 @@ export enum ServerOperation {
|
||||
* Server's failure response to client's request to parse image
|
||||
*/
|
||||
ParseImageFailed = 13,
|
||||
/**
|
||||
* Server's response to client's request to train a message
|
||||
*/
|
||||
TrainedMessage = 14,
|
||||
/**
|
||||
* Server's failure response to client's request to train a message
|
||||
*/
|
||||
TrainMessageFailed = 15,
|
||||
|
||||
/**
|
||||
* Server's disconnect message
|
||||
|
||||
Reference in New Issue
Block a user