Browse Source

Added a SentData event to DiscordVoidAPIClient

pull/157/head
RogueException 9 years ago
parent
commit
556f6a864a
2 changed files with 6 additions and 3 deletions
  1. +0
    -1
      src/Discord.Net/API/DiscordAPIClient.cs
  2. +6
    -2
      src/Discord.Net/API/DiscordVoiceAPIClient.cs

+ 0
- 1
src/Discord.Net/API/DiscordAPIClient.cs View File

@@ -357,7 +357,6 @@ namespace Discord.API
return await SendAsync<Application>("GET", "oauth2/applications/@me", options: options).ConfigureAwait(false);
}


//Auth
public async Task ValidateTokenAsync(RequestOptions options = null)
{


+ 6
- 2
src/Discord.Net/API/DiscordVoiceAPIClient.cs View File

@@ -27,6 +27,8 @@ namespace Discord.Audio
private readonly AsyncEvent<Func<VoiceOpCode, Task>> _sentGatewayMessageEvent = new AsyncEvent<Func<VoiceOpCode, Task>>();
public event Func<Task> SentDiscovery { add { _sentDiscoveryEvent.Add(value); } remove { _sentDiscoveryEvent.Remove(value); } }
private readonly AsyncEvent<Func<Task>> _sentDiscoveryEvent = new AsyncEvent<Func<Task>>();
public event Func<int, Task> SentData { add { _sentDataEvent.Add(value); } remove { _sentDataEvent.Remove(value); } }
private readonly AsyncEvent<Func<int, Task>> _sentDataEvent = new AsyncEvent<Func<int, Task>>();

public event Func<VoiceOpCode, object, Task> ReceivedEvent { add { _receivedEvent.Add(value); } remove { _receivedEvent.Remove(value); } }
private readonly AsyncEvent<Func<VoiceOpCode, object, Task>> _receivedEvent = new AsyncEvent<Func<VoiceOpCode, object, Task>>();
@@ -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)


Loading…
Cancel
Save