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:
SpaceEEC
2017-05-01 00:16:02 +02:00
committed by Crawl
parent 0754ddbc34
commit c5efa985fc

View File

@@ -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;