mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 18:00:08 +00:00
More conversion
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import { loopObject } from "../util/loop_object.ts";
|
||||
import { delay } from "../util/utils.ts";
|
||||
import { ws } from "./ws.ts";
|
||||
import {GatewayManager} from "../bot.ts";
|
||||
|
||||
export async function processQueue(id: number) {
|
||||
const shard = ws.shards.get(id);
|
||||
export async function processQueue(gateway: GatewayManager, id: number) {
|
||||
const shard = gateway.shards.get(id);
|
||||
// If no items or its already processing then exit
|
||||
if (!shard?.queue.length || shard.processingQueue) return;
|
||||
|
||||
shard.processingQueue = true;
|
||||
|
||||
while (shard.queue.length) {
|
||||
if (shard.ws.readyState !== WebSocket.OPEN) {
|
||||
if (shard.gateway.readyState !== WebSocket.OPEN) {
|
||||
shard.processingQueue = false;
|
||||
return;
|
||||
}
|
||||
@@ -34,20 +34,20 @@ export async function processQueue(id: number) {
|
||||
: Array.isArray(value)
|
||||
? value.map((v) => (typeof v === "bigint" ? v.toString() : v))
|
||||
: value,
|
||||
`Running forEach loop in ws.processQueue function for changing bigints to strings.`
|
||||
`Running forEach loop in gateway.processQueue function for changing bigints to strings.`
|
||||
);
|
||||
}
|
||||
|
||||
ws.log("RAW_SEND", shard.id, request);
|
||||
gateway.log("RAW_SEND", shard.id, request);
|
||||
|
||||
shard.ws.send(JSON.stringify(request));
|
||||
shard.gateway.send(JSON.stringify(request));
|
||||
|
||||
// Counter is useful for preventing 120/m requests.
|
||||
shard.queueCounter++;
|
||||
|
||||
// Handle if the requests have been maxed
|
||||
if (shard.queueCounter >= 118) {
|
||||
ws.log("DEBUG", {
|
||||
gateway.log("DEBUG", {
|
||||
message: "Max gateway requests per minute reached setting timeout for one minute",
|
||||
shardId: shard.id,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user