| @@ -127,6 +127,27 @@ | |||||
| <Compile Include="..\Discord.Net\API\WebSockets.cs"> | <Compile Include="..\Discord.Net\API\WebSockets.cs"> | ||||
| <Link>API\WebSockets.cs</Link> | <Link>API\WebSockets.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\Audio\IDiscordVoiceBuffer.cs"> | |||||
| <Link>Audio\IDiscordVoiceBuffer.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Audio\IDiscordVoiceClient.cs"> | |||||
| <Link>Audio\IDiscordVoiceClient.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Audio\Opus.cs"> | |||||
| <Link>Audio\Opus.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Audio\OpusDecoder.cs"> | |||||
| <Link>Audio\OpusDecoder.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Audio\OpusEncoder.cs"> | |||||
| <Link>Audio\OpusEncoder.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Audio\Sodium.cs"> | |||||
| <Link>Audio\Sodium.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Audio\VoiceBuffer.cs"> | |||||
| <Link>Audio\VoiceBuffer.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Collections\AsyncCollection.cs"> | <Compile Include="..\Discord.Net\Collections\AsyncCollection.cs"> | ||||
| <Link>Collections\AsyncCollection.cs</Link> | <Link>Collections\AsyncCollection.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| @@ -223,17 +244,8 @@ | |||||
| <Compile Include="..\Discord.Net\Helpers\TimeoutException.cs"> | <Compile Include="..\Discord.Net\Helpers\TimeoutException.cs"> | ||||
| <Link>Helpers\TimeoutException.cs</Link> | <Link>Helpers\TimeoutException.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\Interop\Opus.cs"> | |||||
| <Link>Interop\Opus.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Interop\OpusDecoder.cs"> | |||||
| <Link>Interop\OpusDecoder.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Interop\OpusEncoder.cs"> | |||||
| <Link>Interop\OpusEncoder.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Interop\Sodium.cs"> | |||||
| <Link>Interop\Sodium.cs</Link> | |||||
| <Compile Include="..\Discord.Net\HttpException.cs"> | |||||
| <Link>HttpException.cs</Link> | |||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\Models\Channel.cs"> | <Compile Include="..\Discord.Net\Models\Channel.cs"> | ||||
| <Link>Models\Channel.cs</Link> | <Link>Models\Channel.cs</Link> | ||||
| @@ -262,9 +274,6 @@ | |||||
| <Compile Include="..\Discord.Net\Models\User.cs"> | <Compile Include="..\Discord.Net\Models\User.cs"> | ||||
| <Link>Models\User.cs</Link> | <Link>Models\User.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\Net\HttpException.cs"> | |||||
| <Link>Net\HttpException.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Net\Rest\IRestEngine.cs"> | <Compile Include="..\Discord.Net\Net\Rest\IRestEngine.cs"> | ||||
| <Link>Net\Rest\IRestEngine.cs</Link> | <Link>Net\Rest\IRestEngine.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| @@ -277,15 +286,6 @@ | |||||
| <Compile Include="..\Discord.Net\Net\Rest\SharpRestEngine.cs"> | <Compile Include="..\Discord.Net\Net\Rest\SharpRestEngine.cs"> | ||||
| <Link>Net\Rest\SharpRestEngine.cs</Link> | <Link>Net\Rest\SharpRestEngine.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\Net\Voice\IDiscordVoiceBuffer.cs"> | |||||
| <Link>Net\Voice\IDiscordVoiceBuffer.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Net\Voice\IDiscordVoiceClient.cs"> | |||||
| <Link>Net\Voice\IDiscordVoiceClient.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Net\Voice\VoiceBuffer.cs"> | |||||
| <Link>Net\Voice\VoiceBuffer.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\Net\WebSockets\DataWebSocket.cs"> | <Compile Include="..\Discord.Net\Net\WebSockets\DataWebSocket.cs"> | ||||
| <Link>Net\WebSockets\DataWebSocket.cs</Link> | <Link>Net\WebSockets\DataWebSocket.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| @@ -326,6 +326,7 @@ | |||||
| <Link>lib\opus.dll</Link> | <Link>lib\opus.dll</Link> | ||||
| </Content> | </Content> | ||||
| </ItemGroup> | </ItemGroup> | ||||
| <ItemGroup /> | |||||
| <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||
| <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||||
| Other similar extension points exist, see Microsoft.Common.targets. | Other similar extension points exist, see Microsoft.Common.targets. | ||||
| @@ -1,4 +1,4 @@ | |||||
| namespace Discord.Net.Voice | |||||
| namespace Discord.Audio | |||||
| { | { | ||||
| public interface IDiscordVoiceBuffer | public interface IDiscordVoiceBuffer | ||||
| { | { | ||||
| @@ -1,6 +1,6 @@ | |||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| namespace Discord.Net.Voice | |||||
| namespace Discord.Audio | |||||
| { | { | ||||
| public interface IDiscordVoiceClient | public interface IDiscordVoiceClient | ||||
| { | { | ||||
| @@ -1,7 +1,7 @@ | |||||
| using System; | using System; | ||||
| using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
| namespace Discord.Interop | |||||
| namespace Discord.Audio | |||||
| { | { | ||||
| internal unsafe static class Opus | internal unsafe static class Opus | ||||
| { | { | ||||
| @@ -1,6 +1,6 @@ | |||||
| using System; | using System; | ||||
| namespace Discord.Interop | |||||
| namespace Discord.Audio | |||||
| { | { | ||||
| /// <summary> Opus codec wrapper. </summary> | /// <summary> Opus codec wrapper. </summary> | ||||
| internal class OpusDecoder : IDisposable | internal class OpusDecoder : IDisposable | ||||
| @@ -1,6 +1,6 @@ | |||||
| using System; | using System; | ||||
| namespace Discord.Interop | |||||
| namespace Discord.Audio | |||||
| { | { | ||||
| /// <summary> Opus codec wrapper. </summary> | /// <summary> Opus codec wrapper. </summary> | ||||
| internal class OpusEncoder : IDisposable | internal class OpusEncoder : IDisposable | ||||
| @@ -1,6 +1,6 @@ | |||||
| using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
| namespace Discord.Interop | |||||
| namespace Discord.Audio | |||||
| { | { | ||||
| internal unsafe static class Sodium | internal unsafe static class Sodium | ||||
| { | { | ||||
| @@ -1,7 +1,7 @@ | |||||
| using System; | using System; | ||||
| using System.Threading; | using System.Threading; | ||||
| namespace Discord.Net.Voice | |||||
| namespace Discord.Audio | |||||
| { | { | ||||
| internal class VoiceBuffer : IDiscordVoiceBuffer | internal class VoiceBuffer : IDiscordVoiceBuffer | ||||
| { | { | ||||
| @@ -1,7 +1,7 @@ | |||||
| using Discord.API; | using Discord.API; | ||||
| using Discord.Audio; | |||||
| using Discord.Collections; | using Discord.Collections; | ||||
| using Discord.Net; | using Discord.Net; | ||||
| using Discord.Net.Voice; | |||||
| using Discord.Net.WebSockets; | using Discord.Net.WebSockets; | ||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| using System; | using System; | ||||
| @@ -780,19 +780,19 @@ namespace Discord | |||||
| => LeaveVoiceServer(server?.Id); | => LeaveVoiceServer(server?.Id); | ||||
| public async Task LeaveVoiceServer(string serverId) | public async Task LeaveVoiceServer(string serverId) | ||||
| { | { | ||||
| CheckReady(); //checkVoice is done inside the voice client | |||||
| CheckReady(checkVoice: true); | |||||
| if (serverId == null) throw new ArgumentNullException(nameof(serverId)); | if (serverId == null) throw new ArgumentNullException(nameof(serverId)); | ||||
| if (Config.EnableVoiceMultiserver) | if (Config.EnableVoiceMultiserver) | ||||
| { | { | ||||
| DiscordWSClient client; | DiscordWSClient client; | ||||
| if (_voiceClients.TryRemove(serverId, out client)) | if (_voiceClients.TryRemove(serverId, out client)) | ||||
| await client.Disconnect(); | |||||
| await client.Disconnect().ConfigureAwait(false); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| await _voiceSocket.Disconnect().ConfigureAwait(false); | |||||
| _dataSocket.SendLeaveVoice(serverId); | _dataSocket.SendLeaveVoice(serverId); | ||||
| await _voiceSocket.Disconnect(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| using Discord.Net.Voice; | |||||
| using Discord.Audio; | |||||
| using System; | using System; | ||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| @@ -20,20 +20,6 @@ namespace Discord | |||||
| await _voiceSocket.WaitForConnection(_config.ConnectionTimeout); | await _voiceSocket.WaitForConnection(_config.ConnectionTimeout); | ||||
| } | } | ||||
| /*async Task IDiscordVoiceClient.Disconnect() | |||||
| { | |||||
| CheckReady(checkVoice: true); | |||||
| if (_voiceSocket.State != WebSocketState.Disconnected) | |||||
| { | |||||
| if (_voiceSocket.CurrentServerId != null) | |||||
| { | |||||
| await _voiceSocket.Disconnect().ConfigureAwait(false); | |||||
| _dataSocket.SendLeaveVoice(_voiceSocket.CurrentServerId); | |||||
| } | |||||
| } | |||||
| }*/ | |||||
| /// <summary> Sends a PCM frame to the voice server. Will block until space frees up in the outgoing buffer. </summary> | /// <summary> Sends a PCM frame to the voice server. Will block until space frees up in the outgoing buffer. </summary> | ||||
| /// <param name="data">PCM frame to send. This must be a single or collection of uncompressed 48Kz monochannel 20ms PCM frames. </param> | /// <param name="data">PCM frame to send. This must be a single or collection of uncompressed 48Kz monochannel 20ms PCM frames. </param> | ||||
| /// <param name="count">Number of bytes in this frame. </param> | /// <param name="count">Number of bytes in this frame. </param> | ||||
| @@ -1,7 +1,7 @@ | |||||
| using System; | using System; | ||||
| using System.Net; | using System.Net; | ||||
| namespace Discord.Net | |||||
| namespace Discord | |||||
| { | { | ||||
| public class HttpException : Exception | public class HttpException : Exception | ||||
| { | { | ||||
| @@ -1,7 +1,6 @@ | |||||
| #define USE_THREAD | #define USE_THREAD | ||||
| using Discord.API; | using Discord.API; | ||||
| using Discord.Interop; | |||||
| using Discord.Net.Voice; | |||||
| using Discord.Audio; | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||
| using System; | using System; | ||||
| @@ -8,7 +8,7 @@ using System.Threading.Tasks; | |||||
| namespace Discord.Net.WebSockets | namespace Discord.Net.WebSockets | ||||
| { | { | ||||
| public enum WebSocketState : byte | |||||
| internal enum WebSocketState : byte | |||||
| { | { | ||||
| Disconnected, | Disconnected, | ||||
| Connecting, | Connecting, | ||||