diff --git a/src/Discord.Net.Audio/AudioClient.cs b/src/Discord.Net.Audio/AudioClient.cs
index 715a565d2..279557029 100644
--- a/src/Discord.Net.Audio/AudioClient.cs
+++ b/src/Discord.Net.Audio/AudioClient.cs
@@ -50,34 +50,21 @@ namespace Discord.Audio
private ConnectionState _gatewayState;
internal Logger Logger { get; }
-
- /// Gets the unique identifier for this client.
+
public int Id { get; }
- /// Gets the service managing this client.
public AudioService Service { get; }
- /// Gets the configuration object used to make this client.
public AudioServiceConfig Config { get; }
- /// Gets the internal RestClient for the Client API endpoint.
public RestClient ClientAPI { get; }
- /// Gets the internal WebSocket for the Gateway event stream.
public GatewaySocket GatewaySocket { get; }
- /// Gets the internal WebSocket for the Voice control stream.
public VoiceSocket VoiceSocket { get; }
- /// Gets the JSON serializer used by this client.
public JsonSerializer Serializer { get; }
- ///
public Stream OutputStream { get; }
-
- /// Gets a cancellation token that triggers when the client is manually disconnected.
+
public CancellationToken CancelToken { get; private set; }
- /// Gets the session id for the current connection.
public string SessionId { get; private set; }
-
- /// Gets the current state of this client.
+
public ConnectionState State => VoiceSocket.State;
- /// Gets the server this client is bound to.
public Server Server => VoiceSocket.Server;
- /// Gets the channel
public Channel Channel => VoiceSocket.Channel;
public AudioClient(DiscordClient client, Server server, int id)
@@ -116,7 +103,6 @@ namespace Discord.Audio
OutputStream = new OutStream(this);
}
- /// Connects to the Discord server with the provided token.
public async Task Connect()
{
if (Config.EnableMultiserver)
@@ -172,7 +158,6 @@ namespace Discord.Audio
_gatewayState = ConnectionState.Connected;
}
- /// Disconnects from the Discord server, canceling any pending requests.
public async Task Disconnect()
{
await _taskManager.Stop(true).ConfigureAwait(false);
@@ -277,9 +262,6 @@ namespace Discord.Audio
}
}
- /// Sends a PCM frame to the voice server. Will block until space frees up in the outgoing buffer.
- /// PCM frame to send. This must be a single or collection of uncompressed 48Kz monochannel 20ms PCM frames.
- /// Number of bytes in this frame.
public void Send(byte[] data, int offset, int count)
{
if (data == null) throw new ArgumentException(nameof(data));
@@ -291,14 +273,11 @@ namespace Discord.Audio
VoiceSocket.SendPCMFrames(data, offset, count);
}
- /// Clears the PCM buffer.
public void Clear()
{
if (VoiceSocket.Server == null) return; //Has been closed
VoiceSocket.ClearPCMFrames();
}
-
- /// Returns a task that completes once the voice output buffer is empty.
public void Wait()
{
if (VoiceSocket.Server == null) return; //Has been closed
diff --git a/src/Discord.Net.Audio/IAudioClient.cs b/src/Discord.Net.Audio/IAudioClient.cs
index 838ec945a..71c8783d5 100644
--- a/src/Discord.Net.Audio/IAudioClient.cs
+++ b/src/Discord.Net.Audio/IAudioClient.cs
@@ -1,16 +1,38 @@
-using System.IO;
+using Discord.Net.Rest;
+using Discord.Net.WebSockets;
+using System.IO;
+using System.Threading;
using System.Threading.Tasks;
namespace Discord.Audio
{
public interface IAudioClient
{
+ /// Gets the unique identifier for this client.
+ int Id { get; }
+ /// Gets the session id for the current connection.
+ string SessionId { get; }
+ /// Gets the current state of this client.
ConnectionState State { get; }
+ /// Gets the channel this client is currently a member of.
Channel Channel { get; }
+ /// Gets the server this client is bound to.
Server Server { get; }
+ /// Gets a stream object that wraps the Send() function.
Stream OutputStream { get; }
+ /// Gets a cancellation token that triggers when the client is manually disconnected.
+ CancellationToken CancelToken { get; }
+ /// Gets the internal RestClient for the Client API endpoint.
+ RestClient ClientAPI { get; }
+ /// Gets the internal WebSocket for the Gateway event stream.
+ GatewaySocket GatewaySocket { get; }
+ /// Gets the internal WebSocket for the Voice control stream.
+ VoiceSocket VoiceSocket { get; }
+
+ /// Moves the client to another channel on the same server.
Task Join(Channel channel);
+ /// Disconnects from the Discord server, canceling any pending requests.
Task Disconnect();
/// Sends a PCM frame to the voice server. Will block until space frees up in the outgoing buffer.
diff --git a/src/Discord.Net.Audio/Opus/OpusConverter.cs b/src/Discord.Net.Audio/Opus/OpusConverter.cs
index 2a5a4f567..25bda033e 100644
--- a/src/Discord.Net.Audio/Opus/OpusConverter.cs
+++ b/src/Discord.Net.Audio/Opus/OpusConverter.cs
@@ -4,13 +4,13 @@ using System.Security;
namespace Discord.Audio.Opus
{
- public enum OpusApplication : int
+ internal enum OpusApplication : int
{
Voice = 2048,
MusicOrMixed = 2049,
LowLatency = 2051
}
- public enum OpusError : int
+ internal enum OpusError : int
{
OK = 0,
BadArg = -1,
@@ -22,7 +22,7 @@ namespace Discord.Audio.Opus
AllocFail = -7
}
- public abstract class OpusConverter : IDisposable
+ internal abstract class OpusConverter : IDisposable
{
protected enum Ctl : int
{
diff --git a/src/Discord.Net.Audio/Opus/OpusDecoder.cs b/src/Discord.Net.Audio/Opus/OpusDecoder.cs
index 9077ea9cf..d8e6b8087 100644
--- a/src/Discord.Net.Audio/Opus/OpusDecoder.cs
+++ b/src/Discord.Net.Audio/Opus/OpusDecoder.cs
@@ -2,7 +2,6 @@
namespace Discord.Audio.Opus
{
- /// Opus codec wrapper.
internal class OpusDecoder : OpusConverter
{
/// Creates a new Opus decoder.
diff --git a/src/Discord.Net.Audio/Opus/OpusEncoder.cs b/src/Discord.Net.Audio/Opus/OpusEncoder.cs
index 258faf481..b41cbb482 100644
--- a/src/Discord.Net.Audio/Opus/OpusEncoder.cs
+++ b/src/Discord.Net.Audio/Opus/OpusEncoder.cs
@@ -2,7 +2,6 @@
namespace Discord.Audio.Opus
{
- /// Opus codec wrapper.
internal class OpusEncoder : OpusConverter
{
/// Gets the bit rate in kbit/s.
diff --git a/src/Discord.Net.Audio/VirtualClient.cs b/src/Discord.Net.Audio/VirtualClient.cs
index 0d197fb95..12d285a0d 100644
--- a/src/Discord.Net.Audio/VirtualClient.cs
+++ b/src/Discord.Net.Audio/VirtualClient.cs
@@ -1,4 +1,7 @@
-using System.IO;
+using Discord.Net.Rest;
+using Discord.Net.WebSockets;
+using System.IO;
+using System.Threading;
using System.Threading.Tasks;
namespace Discord.Audio
@@ -9,9 +12,17 @@ namespace Discord.Audio
public Server Server { get; }
- public ConnectionState State => _client.VoiceSocket.Server == Server ? _client.VoiceSocket.State : ConnectionState.Disconnected;
- public Channel Channel => _client.VoiceSocket.Server == Server ? _client.VoiceSocket.Channel : null;
- public Stream OutputStream => _client.VoiceSocket.Server == Server ? _client.OutputStream : null;
+ public int Id => 0;
+ public string SessionId => _client.Server == Server ? _client.SessionId : null;
+
+ public ConnectionState State => _client.Server == Server ? _client.State : ConnectionState.Disconnected;
+ public Channel Channel => _client.Server == Server ? _client.Channel : null;
+ public Stream OutputStream => _client.Server == Server ? _client.OutputStream : null;
+ public CancellationToken CancelToken => _client.Server == Server ? _client.CancelToken : CancellationToken.None;
+
+ public RestClient ClientAPI => _client.Server == Server ? _client.ClientAPI : null;
+ public GatewaySocket GatewaySocket => _client.Server == Server ? _client.GatewaySocket : null;
+ public VoiceSocket VoiceSocket => _client.Server == Server ? _client.VoiceSocket : null;
public VirtualClient(AudioClient client, Server server)
{