Reorganise disabledEvents stuff

This commit is contained in:
Schuyler Cebulskie
2016-10-09 14:41:57 -04:00
parent 7b571f9729
commit dabe51fc8d
3 changed files with 9 additions and 13 deletions

View File

@@ -59,6 +59,13 @@ class WebSocketManager extends EventEmitter {
*/
this.ws = null;
/**
* An object with keys that are websocket event names that should be ignored
* @type {Object}
*/
this.disabledEvents = {};
for (const event in client.options.disabledEvents) this.disabledEvents[event] = true;
this.first = true;
}
@@ -69,9 +76,7 @@ class WebSocketManager extends EventEmitter {
_connect(gateway) {
this.client.emit('debug', `Connecting to gateway ${gateway}`);
this.normalReady = false;
if (this.status !== Constants.Status.RECONNECTING) {
this.status = Constants.Status.CONNECTING;
}
if (this.status !== Constants.Status.RECONNECTING) this.status = Constants.Status.CONNECTING;
this.ws = new WebSocket(gateway);
this.ws.onopen = () => this.eventOpen();
this.ws.onclose = (d) => this.eventClose(d);