Browse Source

fix: Possible NullReferenceException when receiving InvalidSession (#1695)

tags/2.3.0
Paulo GitHub 4 years ago
parent
commit
5213916903
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions
  1. +12
    -7
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 12
- 7
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -534,15 +534,20 @@ namespace Discord.WebSocket
_sessionId = null;
_lastSeq = 0;

await _shardedClient.AcquireIdentifyLockAsync(ShardId, _connection.CancelToken).ConfigureAwait(false);
try
if (_shardedClient != null)
{
await ApiClient.SendIdentifyAsync(shardID: ShardId, totalShards: TotalShards, guildSubscriptions: _guildSubscriptions, gatewayIntents: _gatewayIntents, presence: BuildCurrentStatus()).ConfigureAwait(false);
}
finally
{
_shardedClient.ReleaseIdentifyLock();
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);
}
break;
case GatewayOpCode.Reconnect:


Loading…
Cancel
Save