mirror of
https://github.com/danbulant/discord.js
synced 2026-06-06 16:22:08 +00: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:
parent
0754ddbc34
commit
c5efa985fc
1 changed files with 10 additions and 0 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue