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
The client that instantiated this WebSocketManager Source
gateway
The gateway this manager uses Source
totalShards
The amount of shards this manager handles Source
shards
A collection of all shards this manager handles Source
shardQueue
An array of shards to be connected or that need to reconnect Source
packetQueue
An array of queued events before this WebSocketManager became ready Source
status
The current status of this WebSocketManager Source
destroyed
If this manager was destroyed. It will prevent shards from reconnecting Source
reconnecting
If this manager is currently reconnecting one or multiple shards Source
ping
The average ping of all WebSocketShards Source
Methods
debug
Emits a debug message. Parameters
| Name | Type | Description |
|---|---|---|
message | string | The debug message |
shard? | WebSocketShard | The shard that emitted this message, if any |
| Source |
connect
Connects this manager to the gateway. Source
createShards
Handles the creation of a shard. Returns: Promise<boolean>Source
reconnect
Handles reconnects for this manager. Returns: Promise<boolean>Source
broadcast
Broadcasts a packet to every shard this manager handles. Parameters
| Name | Type | Description |
|---|---|---|
packet | Object | The packet to send |
| Source |
destroy
Destroys this manager and all its shards. Source
handlePacket
Processes a packet and queues it if this WebSocketManager is not ready. Parameters
| Name | Type | Description |
|---|---|---|
packet? | Object | The packet to be handled |
shard? | WebSocketShard | The shard that will handle this packet |
Returns: booleanSource
checkShardsReady
Checks whether the client is ready to be marked as ready. Source
triggerClientReady
Causes the client to be marked as ready and emits the ready event. Source