mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
feat(packages/api): add force disconnecting and disconnected getter in APIClient
This commit is contained in:
@@ -163,13 +163,17 @@ export default class Client {
|
||||
/**
|
||||
* Disconnects the client from the API
|
||||
*/
|
||||
disconnect() {
|
||||
this.ws.disconnect()
|
||||
disconnect(force?: boolean) {
|
||||
this.ws.disconnect(force)
|
||||
}
|
||||
|
||||
#throwIfNotReady() {
|
||||
if (!this.isReady()) throw new Error('Client is not ready')
|
||||
}
|
||||
|
||||
get disconnected() {
|
||||
return this.ws.disconnected
|
||||
}
|
||||
}
|
||||
|
||||
export class ClientWebSocketPacketAwaiter {
|
||||
|
||||
@@ -137,8 +137,8 @@ export class ClientWebSocketManager {
|
||||
/**
|
||||
* Disconnects from the WebSocket API
|
||||
*/
|
||||
disconnect() {
|
||||
this.#throwIfDisconnected('Cannot disconnect when already disconnected from the server')
|
||||
disconnect(force?: boolean) {
|
||||
if (!force) this.#throwIfDisconnected('Cannot disconnect when already disconnected from the server')
|
||||
this._handleDisconnect(DisconnectReason.PlannedDisconnect)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user