Skip to content

WebSocketManager ​

classe · Source

The WebSocket manager for this client. This class forwards raw dispatch events, read more about it here https://discord.com/developers/docs/topics/gateway

Extends: EventEmitter

Properties ​

client ​

readonly

client: Client

The client that instantiated this WebSocketManager Source

gateway ​

nullable

gateway: string

The gateway this manager uses Source

totalShards ​

private

totalShards: number

The amount of shards this manager handles Source

shards ​

shards: Collection<number, WebSocketShard>

A collection of all shards this manager handles Source

shardQueue ​

private

shardQueue: Set<WebSocketShard>

An array of shards to be connected or that need to reconnect Source

packetQueue ​

private

packetQueue: Array<Object>

An array of queued events before this WebSocketManager became ready Source

status ​

status: Status

The current status of this WebSocketManager Source

destroyed ​

private

destroyed: boolean

If this manager was destroyed. It will prevent shards from reconnecting Source

reconnecting ​

private

reconnecting: boolean

If this manager is currently reconnecting one or multiple shards Source

ping ​

readonly

ping: number

The average ping of all WebSocketShards Source

Methods ​

debug ​

private

debug(message: string, shard?: WebSocketShard)

Emits a debug message. Parameters

NameTypeDescription
messagestringThe debug message
shard?WebSocketShardThe shard that emitted this message, if any
Source

connect ​

async · private

async connect()

Connects this manager to the gateway. Source

createShards ​

async · private

async createShards(): Promise<boolean>

Handles the creation of a shard. Returns: Promise<boolean>Source

reconnect ​

async · private

async reconnect(): Promise<boolean>

Handles reconnects for this manager. Returns: Promise<boolean>Source

broadcast ​

private

broadcast(packet: Object)

Broadcasts a packet to every shard this manager handles. Parameters

NameTypeDescription
packetObjectThe packet to send
Source

destroy ​

private

destroy()

Destroys this manager and all its shards. Source

handlePacket ​

private

handlePacket(packet?: Object, shard?: WebSocketShard): boolean

Processes a packet and queues it if this WebSocketManager is not ready. Parameters

NameTypeDescription
packet?ObjectThe packet to be handled
shard?WebSocketShardThe shard that will handle this packet

Returns: booleanSource

checkShardsReady ​

private

checkShardsReady()

Checks whether the client is ready to be marked as ready. Source

triggerClientReady ​

private

triggerClientReady()

Causes the client to be marked as ready and emits the ready event. Source

Unofficial software. Not affiliated with or supported by Discord.