Break reconnect loop if you client.destroy in the disconnect event (#1371)

* Break reconnect loop if you client.destroy in the disconnect event

* fix lint/long line?

* God this is So UGLY, why...

* Update WebSocketManager.js

* Update WebSocketManager.js
This commit is contained in:
bdistin
2017-04-11 23:31:45 -05:00
committed by Crawl
parent 39f7dc018a
commit c5e2ea7458

View File

@@ -307,7 +307,11 @@ class WebSocketManager extends EventEmitter {
* Tries to reconnect the client, changing the status to Constants.Status.RECONNECTING. * Tries to reconnect the client, changing the status to Constants.Status.RECONNECTING.
*/ */
tryReconnect() { tryReconnect() {
if (this.status === Constants.Status.RECONNECTING || this.status === Constants.Status.CONNECTING) return; if (
this.status === Constants.Status.RECONNECTING ||
this.status === Constants.Status.CONNECTING ||
!this.client.token
) return;
this.status = Constants.Status.RECONNECTING; this.status = Constants.Status.RECONNECTING;
this.ws.close(); this.ws.close();
this.packetManager.handleQueue(); this.packetManager.handleQueue();