Refactored Net.Voice and Interop namespaces

This commit is contained in:
RogueException
2015-10-22 01:47:15 -03:00
parent ea38efd67b
commit 5a8d3f5377
13 changed files with 39 additions and 53 deletions

View File

@@ -127,6 +127,27 @@
<Compile Include="..\Discord.Net\API\WebSockets.cs">
<Link>API\WebSockets.cs</Link>
</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">
<Link>Collections\AsyncCollection.cs</Link>
</Compile>
@@ -223,17 +244,8 @@
<Compile Include="..\Discord.Net\Helpers\TimeoutException.cs">
<Link>Helpers\TimeoutException.cs</Link>
</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 Include="..\Discord.Net\Models\Channel.cs">
<Link>Models\Channel.cs</Link>
@@ -262,9 +274,6 @@
<Compile Include="..\Discord.Net\Models\User.cs">
<Link>Models\User.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\Net\HttpException.cs">
<Link>Net\HttpException.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\Net\Rest\IRestEngine.cs">
<Link>Net\Rest\IRestEngine.cs</Link>
</Compile>
@@ -277,15 +286,6 @@
<Compile Include="..\Discord.Net\Net\Rest\SharpRestEngine.cs">
<Link>Net\Rest\SharpRestEngine.cs</Link>
</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">
<Link>Net\WebSockets\DataWebSocket.cs</Link>
</Compile>
@@ -326,6 +326,7 @@
<Link>lib\opus.dll</Link>
</Content>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.

View File

@@ -1,4 +1,4 @@
namespace Discord.Net.Voice
namespace Discord.Audio
{
public interface IDiscordVoiceBuffer
{

View File

@@ -1,6 +1,6 @@
using System.Threading.Tasks;
namespace Discord.Net.Voice
namespace Discord.Audio
{
public interface IDiscordVoiceClient
{

View File

@@ -1,7 +1,7 @@
using System;
using System.Runtime.InteropServices;
namespace Discord.Interop
namespace Discord.Audio
{
internal unsafe static class Opus
{

View File

@@ -1,6 +1,6 @@
using System;
namespace Discord.Interop
namespace Discord.Audio
{
/// <summary> Opus codec wrapper. </summary>
internal class OpusDecoder : IDisposable

View File

@@ -1,6 +1,6 @@
using System;
namespace Discord.Interop
namespace Discord.Audio
{
/// <summary> Opus codec wrapper. </summary>
internal class OpusEncoder : IDisposable

View File

@@ -1,6 +1,6 @@
using System.Runtime.InteropServices;
namespace Discord.Interop
namespace Discord.Audio
{
internal unsafe static class Sodium
{

View File

@@ -1,7 +1,7 @@
using System;
using System.Threading;
namespace Discord.Net.Voice
namespace Discord.Audio
{
internal class VoiceBuffer : IDiscordVoiceBuffer
{

View File

@@ -1,7 +1,7 @@
using Discord.API;
using Discord.Audio;
using Discord.Collections;
using Discord.Net;
using Discord.Net.Voice;
using Discord.Net.WebSockets;
using Newtonsoft.Json;
using System;
@@ -780,19 +780,19 @@ namespace Discord
=> LeaveVoiceServer(server?.Id);
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 (Config.EnableVoiceMultiserver)
{
DiscordWSClient client;
if (_voiceClients.TryRemove(serverId, out client))
await client.Disconnect();
await client.Disconnect().ConfigureAwait(false);
}
else
{
await _voiceSocket.Disconnect().ConfigureAwait(false);
_dataSocket.SendLeaveVoice(serverId);
await _voiceSocket.Disconnect();
}
}

View File

@@ -1,4 +1,4 @@
using Discord.Net.Voice;
using Discord.Audio;
using System;
using System.Threading.Tasks;
@@ -20,20 +20,6 @@ namespace Discord
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>
/// <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>

View File

@@ -1,7 +1,7 @@
using System;
using System.Net;
namespace Discord.Net
namespace Discord
{
public class HttpException : Exception
{

View File

@@ -1,7 +1,6 @@
#define USE_THREAD
using Discord.API;
using Discord.Interop;
using Discord.Net.Voice;
using Discord.Audio;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;

View File

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Discord.Net.WebSockets
{
public enum WebSocketState : byte
internal enum WebSocketState : byte
{
Disconnected,
Connecting,