fix: Possible NullReferenceException when receiving InvalidSession (#1695)

This commit is contained in:
Paulo
2020-11-25 14:27:26 -03:00
committed by GitHub
parent e3850e1e8f
commit 5213916903

View File

@@ -534,15 +534,20 @@ namespace Discord.WebSocket
_sessionId = null; _sessionId = null;
_lastSeq = 0; _lastSeq = 0;
await _shardedClient.AcquireIdentifyLockAsync(ShardId, _connection.CancelToken).ConfigureAwait(false); if (_shardedClient != null)
try
{ {
await _shardedClient.AcquireIdentifyLockAsync(ShardId, _connection.CancelToken).ConfigureAwait(false);
try
{
await ApiClient.SendIdentifyAsync(shardID: ShardId, totalShards: TotalShards, guildSubscriptions: _guildSubscriptions, gatewayIntents: _gatewayIntents, presence: BuildCurrentStatus()).ConfigureAwait(false);
}
finally
{
_shardedClient.ReleaseIdentifyLock();
}
}
else
await ApiClient.SendIdentifyAsync(shardID: ShardId, totalShards: TotalShards, guildSubscriptions: _guildSubscriptions, gatewayIntents: _gatewayIntents, presence: BuildCurrentStatus()).ConfigureAwait(false); await ApiClient.SendIdentifyAsync(shardID: ShardId, totalShards: TotalShards, guildSubscriptions: _guildSubscriptions, gatewayIntents: _gatewayIntents, presence: BuildCurrentStatus()).ConfigureAwait(false);
}
finally
{
_shardedClient.ReleaseIdentifyLock();
}
} }
break; break;
case GatewayOpCode.Reconnect: case GatewayOpCode.Reconnect: