From 5627fa98649cf824a5ad094920701eb93262cfa4 Mon Sep 17 00:00:00 2001 From: spiral Date: Sun, 26 Dec 2021 01:46:25 -0500 Subject: [PATCH] feat: query identify ratelimiter when identifying instead of when connecting websocket --- Myriad/Gateway/Shard.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Myriad/Gateway/Shard.cs b/Myriad/Gateway/Shard.cs index b4804585..e6b172a1 100644 --- a/Myriad/Gateway/Shard.cs +++ b/Myriad/Gateway/Shard.cs @@ -129,8 +129,6 @@ public class Shard { while (true) { - await _ratelimiter.Identify(_info.ShardId); - _logger.Information("Shard {ShardId}: Connecting to WebSocket", _info.ShardId); try { @@ -149,7 +147,14 @@ public class Shard => _conn.Disconnect(closeStatus, null); private async Task SendIdentify() - => await _conn.Send(new GatewayPacket + { + _logger.Debug("Shard {ShardId}: Requesting identify from ratelimiter", _info.ShardId); + + await _ratelimiter.Identify(_info.ShardId); + + _logger.Debug("Shard {ShardId}: Ratelimiter said OK to identify now", _info.ShardId); + + await _conn.Send(new GatewayPacket { Opcode = GatewayOpcode.Identify, Payload = new GatewayIdentify @@ -167,6 +172,7 @@ public class Shard LargeThreshold = 50 } }); + } private async Task SendResume((string SessionId, int? LastSeq) arg) => await _conn.Send(new GatewayPacket