Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: added GetStreams to AudioClient and IAudioClient #1588

Merged
merged 3 commits into from
Nov 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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