/** * WebSocket reconnection state machine and close-code handler. * * Encapsulates the reconnect delay scheduling, quick-disconnect detection, * and close-code interpretation that both plugin versions share. * * Zero external dependencies — uses only the constants from `./constants.ts`.
*/
import type { EngineLogger } from "../types.js"; import {
RECONNECT_DELAYS,
RATE_LIMIT_DELAY,
MAX_RECONNECT_ATTEMPTS,
MAX_QUICK_DISCONNECT_COUNT,
QUICK_DISCONNECT_THRESHOLD,
GatewayCloseCode,
} from "./constants.js";
/** Actions the caller should take after processing a close event. */
export interface CloseAction { /** Whether to schedule a reconnect. */
shouldReconnect: boolean; /** Custom delay override (ms), or undefined to use the default backoff. */
reconnectDelay?: number; /** Whether the session is invalidated and should be cleared. */
clearSession: boolean; /** Whether the token should be refreshed before reconnecting. */
refreshToken: boolean; /** Whether the bot is fatally blocked (offline/banned) and should stop. */
fatal: boolean; /** Human-readable description of the close reason. */
reason: string;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.