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

@@ -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