mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
Readding Client#disconnect and docs for Client#reconnecting (#1437)
* readded docs for client#reconnecting and client#disconnect * moved disconnect event emitting and clarified emitting reason
This commit is contained in:
@@ -334,6 +334,10 @@ class WebSocketConnection extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
reconnect() {
|
reconnect() {
|
||||||
this.debug('Attemping to reconnect in 5500ms...');
|
this.debug('Attemping to reconnect in 5500ms...');
|
||||||
|
/**
|
||||||
|
* Emitted whenever the client tries to reconnect to the WebSocket.
|
||||||
|
* @event Client#reconnecting
|
||||||
|
*/
|
||||||
this.client.emit(Constants.Events.RECONNECTING);
|
this.client.emit(Constants.Events.RECONNECTING);
|
||||||
this.connect(this.gateway, 5500, true);
|
this.connect(this.gateway, 5500, true);
|
||||||
}
|
}
|
||||||
@@ -364,6 +368,12 @@ class WebSocketConnection extends EventEmitter {
|
|||||||
this.heartbeat(-1);
|
this.heartbeat(-1);
|
||||||
// Should we reconnect?
|
// Should we reconnect?
|
||||||
if (Constants.WSCodes[event.code]) {
|
if (Constants.WSCodes[event.code]) {
|
||||||
|
/**
|
||||||
|
* Emitted when the client's WebSocket disconnects and will no longer attempt to reconnect.
|
||||||
|
* @event Client#disconnect
|
||||||
|
* @param {CloseEvent} event The WebSocket close event
|
||||||
|
*/
|
||||||
|
this.client.emit(Constants.Events.DISCONNECT, event);
|
||||||
this.debug(Constants.WSCodes[event.code]);
|
this.debug(Constants.WSCodes[event.code]);
|
||||||
this.destroy();
|
this.destroy();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user