Browse Source

Removed persistant guild list for user downloads

tags/1.0-rc
RogueException 8 years ago
parent
commit
900b9b082e
1 changed files with 2 additions and 15 deletions
  1. +2
    -15
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 2
- 15
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -40,7 +40,6 @@ namespace Discord.WebSocket
private int _nextAudioId; private int _nextAudioId;
private DateTimeOffset? _statusSince; private DateTimeOffset? _statusSince;
private RestApplication _applicationInfo; private RestApplication _applicationInfo;
private ConcurrentHashSet<ulong> _downloadUsersFor;


/// <summary> Gets the shard of of this client. </summary> /// <summary> Gets the shard of of this client. </summary>
public int ShardId { get; } public int ShardId { get; }
@@ -88,7 +87,6 @@ namespace Discord.WebSocket
WebSocketProvider = config.WebSocketProvider; WebSocketProvider = config.WebSocketProvider;
AlwaysDownloadUsers = config.AlwaysDownloadUsers; AlwaysDownloadUsers = config.AlwaysDownloadUsers;
State = new ClientState(0, 0); State = new ClientState(0, 0);
_downloadUsersFor = new ConcurrentHashSet<ulong>();
_heartbeatTimes = new ConcurrentQueue<long>(); _heartbeatTimes = new ConcurrentQueue<long>();


_stateLock = new SemaphoreSlim(1, 1); _stateLock = new SemaphoreSlim(1, 1);
@@ -120,12 +118,9 @@ namespace Discord.WebSocket


GuildAvailable += g => GuildAvailable += g =>
{ {
if (ConnectionState == ConnectionState.Connected && (AlwaysDownloadUsers || _downloadUsersFor.ContainsKey(g.Id)))
if (ConnectionState == ConnectionState.Connected && AlwaysDownloadUsers && !g.HasAllMembers)
{ {
if (!g.HasAllMembers)
{
var _ = g.DownloadUsersAsync();
}
var _ = g.DownloadUsersAsync();
} }
return Task.Delay(0); return Task.Delay(0);
}; };
@@ -159,7 +154,6 @@ namespace Discord.WebSocket
await StopAsync().ConfigureAwait(false); await StopAsync().ConfigureAwait(false);
_applicationInfo = null; _applicationInfo = null;
_voiceRegions = ImmutableDictionary.Create<string, RestVoiceRegion>(); _voiceRegions = ImmutableDictionary.Create<string, RestVoiceRegion>();
_downloadUsersFor.Clear();
} }


public async Task StartAsync() public async Task StartAsync()
@@ -192,9 +186,6 @@ namespace Discord.WebSocket
await _gatewayLogger.DebugAsync("Sending Status").ConfigureAwait(false); await _gatewayLogger.DebugAsync("Sending Status").ConfigureAwait(false);
await SendStatusAsync().ConfigureAwait(false); await SendStatusAsync().ConfigureAwait(false);

await ProcessUserDownloadsAsync(_downloadUsersFor.Select(x => GetGuild(x))
.Where(x => x != null).ToImmutableArray()).ConfigureAwait(false);
} }
finally finally
{ {
@@ -317,9 +308,6 @@ namespace Discord.WebSocket
/// <summary> Downloads the users list for the provided guilds, if they don't have a complete list. </summary> /// <summary> Downloads the users list for the provided guilds, if they don't have a complete list. </summary>
public async Task DownloadUsersAsync(IEnumerable<IGuild> guilds) public async Task DownloadUsersAsync(IEnumerable<IGuild> guilds)
{ {
foreach (var guild in guilds)
_downloadUsersFor.TryAdd(guild.Id);

if (ConnectionState == ConnectionState.Connected) if (ConnectionState == ConnectionState.Connected)
{ {
//Race condition leads to guilds being requested twice, probably okay //Race condition leads to guilds being requested twice, probably okay
@@ -664,7 +652,6 @@ namespace Discord.WebSocket
{ {
await _gatewayLogger.DebugAsync($"Received Dispatch (GUILD_DELETE)").ConfigureAwait(false); await _gatewayLogger.DebugAsync($"Received Dispatch (GUILD_DELETE)").ConfigureAwait(false);


_downloadUsersFor.TryRemove(data.Id);
var guild = RemoveGuild(data.Id); var guild = RemoveGuild(data.Id);
if (guild != null) if (guild != null)
{ {


Loading…
Cancel
Save