Class: WebSocketManager

WebSocketManager

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

Constructor

new WebSocketManager()

Source:

Extends

  • EventEmitter

Members

(readonly) client :Client

The client that instantiated this WebSocketManager
Type:
Source:

(private) destroyed :boolean

If this manager was destroyed. It will prevent shards from reconnecting
Type:
  • boolean
Source:

(nullable) gateway :string

The gateway this manager uses
Type:
  • string
Source:

(private) packetQueue :Array.<object>

An array of queued events before this WebSocketManager became ready
Type:
  • Array.<object>
Source:

(readonly) ping :number

The average ping of all WebSocketShards
Type:
  • number
Source:

(private) reconnecting :boolean

If this manager is currently reconnecting one or multiple shards
Type:
  • boolean
Source:

(private, nullable) sessionStartLimit :Object

The current session limit of the client
Type:
  • Object
Properties:
Name Type Description
total number Total number of identifies available
remaining number Number of identifies remaining
reset_after number Number of milliseconds after which the limit resets
Source:

(private) shardQueue :Set.<WebSocketShard>

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

shards :Collection.<number, WebSocketShard>

A collection of all shards this manager handles
Type:
Source:

status :number

The current status of this WebSocketManager
Type:
  • number
Source:

(private) totalShards :number

The amount of shards this manager handles
Type:
  • number
Source:

Methods

(async, private) _handleSessionLimit(remainingopt, resetAfteropt)

Handles the timeout required if we cannot identify anymore.
Parameters:
Name Type Attributes Description
remaining number <optional>
The amount of remaining identify sessions that can be done today
resetAfter number <optional>
The amount of time in which the identify counter resets
Source:

(private) broadcast(packet)

Broadcasts a packet to every shard this manager handles.
Parameters:
Name Type Description
packet Object The packet to send
Source:

(async, private) checkShardsReady()

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

(async, private) connect()

Connects this manager to the gateway.
Source:

(async, private) createShards() → {Promise.<boolean>}

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

(private) debug(message, shardopt, nullable)

Emits a debug message.
Parameters:
Name Type Attributes Description
message string The debug message
shard WebSocketShard <optional>
<nullable>
The shard that emitted this message, if any
Source:

(private) destroy()

Destroys this manager and all its shards.
Source:

(private) handlePacket(packetopt, shardopt) → {boolean}

Processes a packet and queues it if this WebSocketManager is not ready.
Parameters:
Name Type Attributes Description
packet Object <optional>
The packet to be handled
shard WebSocketShard <optional>
The shard that will handle this packet
Source:
Returns:
Type
boolean

(async, private) reconnect(skipLimitopt) → {Promise.<boolean>}

Handles reconnects for this manager.
Parameters:
Name Type Attributes Default Description
skipLimit boolean <optional>
false IF this reconnect should skip checking the session limit
Source:
Returns:
Type
Promise.<boolean>

(private) triggerClientReady()

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