mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
Merge branch 'master' of https://github.com/discordeno/discordeno into proxy-ws
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020-2021 discordeno
|
Copyright (c) 2020-2021 Discordeno
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -77,4 +77,4 @@ We appreciate your help! Before contributing, please read the
|
|||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
[MIT © discordeno](https://github.com/discordeno/discordeno/blob/master/LICENSE)
|
[License can be found here](https://github.com/discordeno/discordeno/blob/master/LICENSE)
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ export async function processQueue(id: string) {
|
|||||||
// SOMETIMES DISCORD RETURNS AN EMPTY 204 RESPONSE THAT CAN'T BE MADE TO JSON
|
// SOMETIMES DISCORD RETURNS AN EMPTY 204 RESPONSE THAT CAN'T BE MADE TO JSON
|
||||||
if (response.status === 204) {
|
if (response.status === 204) {
|
||||||
restCache.eventHandlers.fetchSuccess(queuedRequest.payload);
|
restCache.eventHandlers.fetchSuccess(queuedRequest.payload);
|
||||||
|
// REMOVE FROM QUEUE
|
||||||
|
queue.shift();
|
||||||
queuedRequest.request.respond({ status: 204 });
|
queuedRequest.request.respond({ status: 204 });
|
||||||
} else {
|
} else {
|
||||||
// CONVERT THE RESPONSE TO JSON
|
// CONVERT THE RESPONSE TO JSON
|
||||||
|
|||||||
@@ -163,6 +163,8 @@ export function createShard(
|
|||||||
data: { shardID: basicShard.id, code, reason, wasClean },
|
data: { shardID: basicShard.id, code, reason, wasClean },
|
||||||
});
|
});
|
||||||
createShard(data, identifyPayload, false, shardID);
|
createShard(data, identifyPayload, false, shardID);
|
||||||
|
} else if (code === 3069 && reason === "[discordeno] requested closure") {
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
basicShard.needToResume = true;
|
basicShard.needToResume = true;
|
||||||
await resumeConnection(botGatewayData, identifyPayload, shardID);
|
await resumeConnection(botGatewayData, identifyPayload, shardID);
|
||||||
@@ -407,5 +409,16 @@ export function sendWS(payload: DiscordPayload, shardID = 0) {
|
|||||||
|
|
||||||
const serialized = JSON.stringify(payload);
|
const serialized = JSON.stringify(payload);
|
||||||
shard.ws.send(serialized);
|
shard.ws.send(serialized);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Closes the WebSocket connection or connection attempt */
|
||||||
|
export function closeWS(shardID = 0) {
|
||||||
|
const shard = basicShards.get(shardID);
|
||||||
|
if (!shard) return false;
|
||||||
|
|
||||||
|
shard.ws.close(3069, "[discordeno] requested closure");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user