Moved Frame models, added default providers

This commit is contained in:
RogueException
2017-02-17 23:06:18 -04:00
parent 9d7073fafe
commit d321ad3e5c
10 changed files with 81 additions and 8 deletions

View File

@@ -0,0 +1,27 @@
using System;
namespace Discord.Net.Udp
{
public static class DefaultUdpSocketProvider
{
#if NETSTANDARD1_3
public static readonly UdpSocketProvider Instance = () =>
{
try
{
return new DefaultUdpSocket();
}
catch (PlatformNotSupportedException ex)
{
throw new PlatformNotSupportedException("The default UdpSocketProvider is not supported on this platform.", ex);
}
};
#else
public static readonly UdpSocketProvider Instance = () =>
{
throw new PlatformNotSupportedException("The default UdpSocketProvider is not supported on this platform.\n" +
"You must specify a UdpSocketProvider or target a runtime supporting .NET Standard 1.3, such as .NET Framework 4.6+.");
};
#endif
}
}

View File

@@ -206,15 +206,11 @@ namespace Discord.Net.WebSockets
//Use the internal buffer if we can get it
resultCount = (int)stream.Length;
#if NETSTANDARD1_3
ArraySegment<byte> streamBuffer;
if (stream.TryGetBuffer(out streamBuffer))
result = streamBuffer.Array;
else
result = stream.ToArray();
#else
result = stream.ToArray();
#endif
}
}
else

View File

@@ -0,0 +1,27 @@
using System;
namespace Discord.Net.WebSockets
{
public static class DefaultWebSocketProvider
{
#if NETSTANDARD1_3
public static readonly WebSocketProvider Instance = () =>
{
try
{
return new DefaultWebSocketClient();
}
catch (PlatformNotSupportedException ex)
{
throw new PlatformNotSupportedException("The default WebSocketProvider is not supported on this platform.", ex);
}
};
#else
public static readonly WebSocketProvider Instance = () =>
{
throw new PlatformNotSupportedException("The default WebSocketProvider is not supported on this platform.\n" +
"You must specify a WebSocketProvider or target a runtime supporting .NET Standard 1.3, such as .NET Framework 4.6+.");
};
#endif
}
}