diff --git a/src/Discord.Net.Core/Audio/IAudioClient.cs b/src/Discord.Net.Core/Audio/IAudioClient.cs index 472ad32f1..779228897 100644 --- a/src/Discord.Net.Core/Audio/IAudioClient.cs +++ b/src/Discord.Net.Core/Audio/IAudioClient.cs @@ -5,14 +5,16 @@ namespace Discord.Audio { public interface IAudioClient : IDisposable { - event Func Connected; - event Func Disconnected; + event Func Connected; + event Func Disconnected; event Func LatencyUpdated; /// Gets the current connection state of this client. ConnectionState ConnectionState { get; } /// Gets the estimated round-trip latency, in milliseconds, to the gateway server. int Latency { get; } + /// Gets the Guild this client is in. + IGuild Guild { get; } Task DisconnectAsync(); diff --git a/src/Discord.Net.WebSocket/Audio/AudioClient.cs b/src/Discord.Net.WebSocket/Audio/AudioClient.cs index 5bedf1786..39f14e956 100644 --- a/src/Discord.Net.WebSocket/Audio/AudioClient.cs +++ b/src/Discord.Net.WebSocket/Audio/AudioClient.cs @@ -14,18 +14,18 @@ namespace Discord.Audio { internal class AudioClient : IAudioClient, IDisposable { - public event Func Connected + public event Func Connected { add { _connectedEvent.Add(value); } remove { _connectedEvent.Remove(value); } } - private readonly AsyncEvent> _connectedEvent = new AsyncEvent>(); - public event Func Disconnected + private readonly AsyncEvent> _connectedEvent = new AsyncEvent>(); + public event Func Disconnected { add { _disconnectedEvent.Add(value); } remove { _disconnectedEvent.Remove(value); } } - private readonly AsyncEvent> _disconnectedEvent = new AsyncEvent>(); + private readonly AsyncEvent> _disconnectedEvent = new AsyncEvent>(); public event Func LatencyUpdated { add { _latencyUpdatedEvent.Add(value); } @@ -115,7 +115,7 @@ namespace Discord.Audio await ApiClient.SendIdentityAsync(userId, sessionId, token).ConfigureAwait(false); await _connectTask.Task.ConfigureAwait(false); - await _connectedEvent.InvokeAsync().ConfigureAwait(false); + await _connectedEvent.InvokeAsync(this).ConfigureAwait(false); ConnectionState = ConnectionState.Connected; await _audioLogger.InfoAsync("Connected").ConfigureAwait(false); } @@ -164,7 +164,7 @@ namespace Discord.Audio ConnectionState = ConnectionState.Disconnected; await _audioLogger.InfoAsync("Disconnected").ConfigureAwait(false); - await _disconnectedEvent.InvokeAsync(ex).ConfigureAwait(false); + await _disconnectedEvent.InvokeAsync(this, ex).ConfigureAwait(false); await Discord.ApiClient.SendVoiceStateUpdateAsync(Guild.Id, null, false, false).ConfigureAwait(false); } @@ -311,6 +311,9 @@ namespace Discord.Audio } catch (OperationCanceledException) { } } + + /// + IGuild IAudioClient.Guild => Guild; internal void Dispose(bool disposing) {