mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
Fix #657
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -75,7 +75,7 @@ class WebSocketManager {
|
|||||||
*/
|
*/
|
||||||
send(data, force = false) {
|
send(data, force = false) {
|
||||||
if (force) {
|
if (force) {
|
||||||
this.ws.send(JSON.stringify(data));
|
this._send(JSON.stringify(data));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._queue.push(JSON.stringify(data));
|
this._queue.push(JSON.stringify(data));
|
||||||
@@ -88,6 +88,12 @@ class WebSocketManager {
|
|||||||
this.status = Constants.Status.IDLE;
|
this.status = Constants.Status.IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_send(data) {
|
||||||
|
if (this.ws.readyState === WebSocket.OPEN) {
|
||||||
|
this.ws.send(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
doQueue() {
|
doQueue() {
|
||||||
const item = this._queue[0];
|
const item = this._queue[0];
|
||||||
if (this.ws.readyState === WebSocket.OPEN && item) {
|
if (this.ws.readyState === WebSocket.OPEN && item) {
|
||||||
@@ -98,7 +104,7 @@ class WebSocketManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._remaining--;
|
this._remaining--;
|
||||||
this.ws.send(item);
|
this._send(item);
|
||||||
this._queue.shift();
|
this._queue.shift();
|
||||||
this.doQueue();
|
this.doQueue();
|
||||||
this.client.setTimeout(() => this._remaining++, 1000);
|
this.client.setTimeout(() => this._remaining++, 1000);
|
||||||
|
|||||||
Reference in New Issue
Block a user