From 92854150b2a470c9835ce42504a6f5a2ed377ea8 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Mon, 15 Feb 2021 23:59:06 +0000 Subject: [PATCH] finalizing comments --- src/ws/proxy/manager.ts | 1 - src/ws/proxy/ws.ts | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ws/proxy/manager.ts b/src/ws/proxy/manager.ts index b39025287..149399a79 100644 --- a/src/ws/proxy/manager.ts +++ b/src/ws/proxy/manager.ts @@ -104,7 +104,6 @@ export async function tellClusterToIdentify( ) { // When resharding const oldShard = ws.shards.get(shardID); - // TODO: resolve promise 5 sec after ready await ws.identify(shardID, ws.maxShards); if (oldShard) { diff --git a/src/ws/proxy/ws.ts b/src/ws/proxy/ws.ts index 7c7bc5a1f..2d52ffed0 100644 --- a/src/ws/proxy/ws.ts +++ b/src/ws/proxy/ws.ts @@ -60,9 +60,9 @@ export const ws = { /** Milliseconds left until limit is reset. */ resetAfter: 0, /** The number of identify requests allowed per 5 seconds. - * So, if you had a max concurrency of 16, and 16 shards for example, you could start them all up at the same time. - * Whereas if you had 32 shards, if you tried to start up shard 0 and 16 at the same time for example, it would not work. You can start shards 0-15 concurrently, then 16-31... - * */ + * So, if you had a max concurrency of 16, and 16 shards for example, you could start them all up at the same time. + * Whereas if you had 32 shards, if you tried to start up shard 0 and 16 at the same time for example, it would not work. You can start shards 0-15 concurrently, then 16-31... + */ maxConcurrency: 1, }, }, @@ -84,13 +84,21 @@ export const ws = { startGateway, /** The handler for spawning ALL the shards. */ spawnShards, + /** Create the websocket and adds the proper handlers to the websocket. */ createShard, + /** Begins identification of the shard to discord */ identify, + /** Begins heartbeating of the shard to keep it alive */ heartbeat, + /** Sends the discord payload to another server. */ handleDiscordPayload, + /** Tell the cluster/worker to begin identifying this shard */ tellClusterToIdentify, + /** Handle the different logs. Used for debugging. */ log, + /** Handles resharding the bot when necessary. */ resharder, + /** Cleanups loading shards that were unable to load. */ cleanupLoadingShards, }; @@ -99,6 +107,7 @@ export interface DiscordenoShard { id: number; /** The websocket for this shard */ ws: WebSocket; + /** The amount of milliseconds to wait between heartbeats */ resumeInterval: number; /** The session id important for resuming connections. */ sessionID: string;