From c5efa985fc8ee789b8f6d82d1a16c212f8e4df75 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Mon, 1 May 2017 00:16:02 +0200 Subject: [PATCH] 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 --- src/client/websocket/WebSocketConnection.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/client/websocket/WebSocketConnection.js b/src/client/websocket/WebSocketConnection.js index 189cd2cdf..14de7859a 100644 --- a/src/client/websocket/WebSocketConnection.js +++ b/src/client/websocket/WebSocketConnection.js @@ -334,6 +334,10 @@ class WebSocketConnection extends EventEmitter { */ reconnect() { 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.connect(this.gateway, 5500, true); } @@ -364,6 +368,12 @@ class WebSocketConnection extends EventEmitter { this.heartbeat(-1); // Should we reconnect? 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.destroy(); return;