mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Fix endless reconnection bug (#1389)
This commit is contained in:
@@ -82,10 +82,10 @@ class WebSocketManager extends EventEmitter {
|
||||
this.normalReady = false;
|
||||
if (this.status !== Constants.Status.RECONNECTING) this.status = Constants.Status.CONNECTING;
|
||||
this.ws = new WebSocketConnection(gateway);
|
||||
this.ws.e.on('open', this.eventOpen.bind(this));
|
||||
this.ws.e.on('packet', this.eventPacket.bind(this));
|
||||
this.ws.e.on('close', this.eventClose.bind(this));
|
||||
this.ws.e.on('error', this.eventError.bind(this));
|
||||
this.ws.on('open', this.eventOpen.bind(this));
|
||||
this.ws.on('packet', this.eventPacket.bind(this));
|
||||
this.ws.on('close', this.eventClose.bind(this));
|
||||
this.ws.on('error', this.eventError.bind(this));
|
||||
this._queue = [];
|
||||
this._remaining = 120;
|
||||
this.client.setInterval(() => {
|
||||
@@ -141,7 +141,7 @@ class WebSocketManager extends EventEmitter {
|
||||
}
|
||||
|
||||
_send(data) {
|
||||
if (this.ws.readyState === WebSocketConnection.OPEN) {
|
||||
if (this.ws.readyState === WebSocketConnection.WebSocket.OPEN) {
|
||||
this.emit('send', data);
|
||||
this.ws.send(data);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ class WebSocketManager extends EventEmitter {
|
||||
|
||||
doQueue() {
|
||||
const item = this._queue[0];
|
||||
if (!(this.ws.readyState === WebSocketConnection.OPEN && item)) return;
|
||||
if (!(this.ws.readyState === WebSocketConnection.WebSocket.OPEN && item)) return;
|
||||
if (this.remaining === 0) {
|
||||
this.client.setTimeout(this.doQueue.bind(this), Date.now() - this.remainingReset);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user