From 556f6a864a8a51fc28cfccb30853c2b1785a478d Mon Sep 17 00:00:00 2001 From: RogueException Date: Thu, 21 Jul 2016 17:46:42 -0300 Subject: [PATCH] Added a SentData event to DiscordVoidAPIClient --- src/Discord.Net/API/DiscordAPIClient.cs | 1 - src/Discord.Net/API/DiscordVoiceAPIClient.cs | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Discord.Net/API/DiscordAPIClient.cs b/src/Discord.Net/API/DiscordAPIClient.cs index f13439517..ff8e30782 100644 --- a/src/Discord.Net/API/DiscordAPIClient.cs +++ b/src/Discord.Net/API/DiscordAPIClient.cs @@ -357,7 +357,6 @@ namespace Discord.API return await SendAsync("GET", "oauth2/applications/@me", options: options).ConfigureAwait(false); } - //Auth public async Task ValidateTokenAsync(RequestOptions options = null) { diff --git a/src/Discord.Net/API/DiscordVoiceAPIClient.cs b/src/Discord.Net/API/DiscordVoiceAPIClient.cs index 2b278d903..dbd1ac838 100644 --- a/src/Discord.Net/API/DiscordVoiceAPIClient.cs +++ b/src/Discord.Net/API/DiscordVoiceAPIClient.cs @@ -27,6 +27,8 @@ namespace Discord.Audio private readonly AsyncEvent> _sentGatewayMessageEvent = new AsyncEvent>(); public event Func SentDiscovery { add { _sentDiscoveryEvent.Add(value); } remove { _sentDiscoveryEvent.Remove(value); } } private readonly AsyncEvent> _sentDiscoveryEvent = new AsyncEvent>(); + public event Func SentData { add { _sentDataEvent.Add(value); } remove { _sentDataEvent.Remove(value); } } + private readonly AsyncEvent> _sentDataEvent = new AsyncEvent>(); public event Func ReceivedEvent { add { _receivedEvent.Add(value); } remove { _receivedEvent.Remove(value); } } private readonly AsyncEvent> _receivedEvent = new AsyncEvent>(); @@ -110,9 +112,10 @@ namespace Discord.Audio { if (_udpEndpoint != null) { - await _udp.SendAsync(data, bytes, _udpEndpoint).ConfigureAwait(false); - await _sentDiscoveryEvent.InvokeAsync().ConfigureAwait(false); + await _udp.SendAsync(data, bytes, _udpEndpoint).ConfigureAwait(false); + await _sentDataEvent.InvokeAsync(bytes).ConfigureAwait(false); } + } //WebSocket @@ -214,6 +217,7 @@ namespace Discord.Audio packet[2] = (byte)(ssrc >> 8); packet[3] = (byte)(ssrc >> 0); await SendAsync(packet, 70).ConfigureAwait(false); + await _sentDiscoveryEvent.InvokeAsync().ConfigureAwait(false); } public void SetUdpEndpoint(IPEndPoint endpoint)