Added IDisposable to DiscordClients, removed unused property
This commit is contained in:
@@ -99,6 +99,8 @@ namespace Discord.API
|
||||
{
|
||||
_loginCancelToken?.Dispose();
|
||||
_connectCancelToken?.Dispose();
|
||||
(_restClient as IDisposable)?.Dispose();
|
||||
(_gatewayClient as IDisposable)?.Dispose();
|
||||
}
|
||||
_isDisposed = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Extensions;
|
||||
using Discord.Logging;
|
||||
using Discord.Net;
|
||||
using Discord.Net.Queue;
|
||||
@@ -56,7 +55,7 @@ namespace Discord
|
||||
if (bucket == null && id != null)
|
||||
await _queueLogger.WarningAsync($"Unknown rate limit bucket \"{id ?? "null"}\"").ConfigureAwait(false);
|
||||
};
|
||||
|
||||
|
||||
ApiClient = new API.DiscordApiClient(config.RestClientProvider, (config as DiscordSocketConfig)?.WebSocketProvider, requestQueue: _requestQueue);
|
||||
ApiClient.SentRequest += async (method, endpoint, millis) => await _restLogger.VerboseAsync($"{method} {endpoint}: {millis} ms").ConfigureAwait(false);
|
||||
}
|
||||
@@ -256,10 +255,11 @@ namespace Discord
|
||||
return models.Select(x => new VoiceRegion(x)).Where(x => x.Id == id).FirstOrDefault();
|
||||
}
|
||||
|
||||
internal void Dispose(bool disposing)
|
||||
internal virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
_isDisposed = true;
|
||||
ApiClient.Dispose();
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public void Dispose() => Dispose(true);
|
||||
|
||||
@@ -47,8 +47,7 @@ namespace Discord
|
||||
public ConnectionState ConnectionState { get; private set; }
|
||||
/// <summary> Gets the estimated round-trip latency, in milliseconds, to the gateway server. </summary>
|
||||
public int Latency { get; private set; }
|
||||
|
||||
internal IWebSocketClient GatewaySocket { get; private set; }
|
||||
|
||||
internal int MessageCacheSize { get; private set; }
|
||||
internal DataStore DataStore { get; private set; }
|
||||
|
||||
@@ -97,7 +96,6 @@ namespace Discord
|
||||
else
|
||||
await _gatewayLogger.WarningAsync($"Connection Closed").ConfigureAwait(false);
|
||||
};
|
||||
GatewaySocket = config.WebSocketProvider();
|
||||
|
||||
_voiceRegions = ImmutableDictionary.Create<string, VoiceRegion>();
|
||||
_largeGuilds = new ConcurrentQueue<ulong>();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.API;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
@@ -6,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Discord
|
||||
{
|
||||
//TODO: Add docstrings
|
||||
public interface IDiscordClient
|
||||
public interface IDiscordClient : IDisposable
|
||||
{
|
||||
LoginState LoginState { get; }
|
||||
ConnectionState ConnectionState { get; }
|
||||
|
||||
Reference in New Issue
Block a user