Browse Source

Refactored Net.Voice and Interop namespaces

tags/docs-0.9
RogueException 9 years ago
parent
commit
5a8d3f5377
13 changed files with 39 additions and 53 deletions
  1. +24
    -23
      src/Discord.Net.Net45/Discord.Net.csproj
  2. +1
    -1
      src/Discord.Net/Audio/IDiscordVoiceBuffer.cs
  3. +1
    -1
      src/Discord.Net/Audio/IDiscordVoiceClient.cs
  4. +1
    -1
      src/Discord.Net/Audio/Opus.cs
  5. +1
    -1
      src/Discord.Net/Audio/OpusDecoder.cs
  6. +1
    -1
      src/Discord.Net/Audio/OpusEncoder.cs
  7. +1
    -1
      src/Discord.Net/Audio/Sodium.cs
  8. +1
    -1
      src/Discord.Net/Audio/VoiceBuffer.cs
  9. +4
    -4
      src/Discord.Net/DiscordClient.cs
  10. +1
    -15
      src/Discord.Net/DiscordWSClient.Voice.cs
  11. +1
    -1
      src/Discord.Net/HttpException.cs
  12. +1
    -2
      src/Discord.Net/Net/WebSockets/VoiceWebSocket.cs
  13. +1
    -1
      src/Discord.Net/Net/WebSockets/WebSocket.cs

+ 24
- 23
src/Discord.Net.Net45/Discord.Net.csproj View File

@@ -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.


src/Discord.Net/Net/Voice/IDiscordVoiceBuffer.cs → src/Discord.Net/Audio/IDiscordVoiceBuffer.cs View File

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

src/Discord.Net/Net/Voice/IDiscordVoiceClient.cs → src/Discord.Net/Audio/IDiscordVoiceClient.cs View File

@@ -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
{ {

src/Discord.Net/Interop/Opus.cs → src/Discord.Net/Audio/Opus.cs View File

@@ -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
{ {

src/Discord.Net/Interop/OpusDecoder.cs → src/Discord.Net/Audio/OpusDecoder.cs View File

@@ -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

src/Discord.Net/Interop/OpusEncoder.cs → src/Discord.Net/Audio/OpusEncoder.cs View File

@@ -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

src/Discord.Net/Interop/Sodium.cs → src/Discord.Net/Audio/Sodium.cs View File

@@ -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
{ {

src/Discord.Net/Net/Voice/VoiceBuffer.cs → src/Discord.Net/Audio/VoiceBuffer.cs View File

@@ -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
{ {

+ 4
- 4
src/Discord.Net/DiscordClient.cs View File

@@ -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
- 15
src/Discord.Net/DiscordWSClient.Voice.cs View File

@@ -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>


src/Discord.Net/Net/HttpException.cs → src/Discord.Net/HttpException.cs View File

@@ -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
- 2
src/Discord.Net/Net/WebSockets/VoiceWebSocket.cs View File

@@ -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;


+ 1
- 1
src/Discord.Net/Net/WebSockets/WebSocket.cs View File

@@ -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,


Loading…
Cancel
Save