feature: Add GetStreams to AudioClient (#1588)

* Added GetStreams

* Change return type

* Change return type on the interface

Co-authored-by: Paulo <pnmanjos@hotmail.com>
This commit is contained in:
Jack Fox
2020-11-08 16:21:51 -05:00
committed by GitHub
parent 10fcde0a32
commit 1e012ac0b8
2 changed files with 12 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Discord.Audio
@@ -20,6 +21,9 @@ namespace Discord.Audio
/// <summary> Gets the estimated round-trip latency, in milliseconds, to the voice UDP server. </summary>
int UdpLatency { get; }
/// <summary>Gets the current audio streams.</summary>
IReadOnlyDictionary<ulong, AudioInStream> GetStreams();
Task StopAsync();
Task SetSpeakingAsync(bool value);

View File

@@ -99,6 +99,12 @@ namespace Discord.Audio
_token = token;
await _connection.StartAsync().ConfigureAwait(false);
}
public IReadOnlyDictionary<ulong, AudioInStream> GetStreams()
{
return _streams.ToDictionary(pair => pair.Key, pair => pair.Value.Reader);
}
public async Task StopAsync()
{
await _connection.StopAsync().ConfigureAwait(false);
@@ -379,7 +385,7 @@ namespace Discord.Audio
private async Task RunHeartbeatAsync(int intervalMillis, CancellationToken cancelToken)
{
//TODO: Clean this up when Discord's session patch is live
// TODO: Clean this up when Discord's session patch is live
try
{
await _audioLogger.DebugAsync("Heartbeat Started").ConfigureAwait(false);