Skip to content

Commit

Permalink
feature: Add GetStreams to AudioClient (#1588)
Browse files Browse the repository at this point in the history
* Added GetStreams

* Change return type

* Change return type on the interface

Co-authored-by: Paulo <pnmanjos@hotmail.com>
  • Loading branch information
OutOfBears and SubZero0 authored Nov 8, 2020
1 parent 10fcde0 commit 1e012ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Discord.Net.Core/Audio/IAudioClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Discord.Audio
Expand All @@ -20,6 +21,9 @@ public interface IAudioClient : IDisposable
/// <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);

Expand Down
8 changes: 7 additions & 1 deletion src/Discord.Net.WebSocket/Audio/AudioClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ internal async Task StartAsync(string url, ulong userId, string sessionId, strin
_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);
Expand Down Expand Up @@ -379,7 +385,7 @@ private async Task ProcessPacketAsync(byte[] packet)

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);
Expand Down

0 comments on commit 1e012ac

Please sign in to comment.