Moved Frame models, added default providers
This commit is contained in:
17
src/Discord.Net.WebSocket/API/SocketFrame.cs
Normal file
17
src/Discord.Net.WebSocket/API/SocketFrame.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
internal class SocketFrame
|
||||
{
|
||||
[JsonProperty("op")]
|
||||
public int Operation { get; set; }
|
||||
[JsonProperty("t", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string Type { get; set; }
|
||||
[JsonProperty("s", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public int? Sequence { get; set; }
|
||||
[JsonProperty("d")]
|
||||
public object Payload { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace Discord.WebSocket
|
||||
}
|
||||
}
|
||||
private static API.DiscordSocketApiClient CreateApiClient(DiscordSocketConfig config)
|
||||
=> new API.DiscordSocketApiClient(config.RestClientProvider, DiscordRestConfig.UserAgent, config.WebSocketProvider);
|
||||
=> new API.DiscordSocketApiClient(config.RestClientProvider, config.WebSocketProvider, DiscordRestConfig.UserAgent);
|
||||
|
||||
protected override async Task OnLoginAsync(TokenType tokenType, string token)
|
||||
{
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Discord.WebSocket
|
||||
_largeGuilds = new ConcurrentQueue<ulong>();
|
||||
}
|
||||
private static API.DiscordSocketApiClient CreateApiClient(DiscordSocketConfig config)
|
||||
=> new API.DiscordSocketApiClient(config.RestClientProvider, DiscordRestConfig.UserAgent, config.WebSocketProvider);
|
||||
=> new API.DiscordSocketApiClient(config.RestClientProvider, config.WebSocketProvider, DiscordRestConfig.UserAgent);
|
||||
|
||||
protected override async Task OnLoginAsync(TokenType tokenType, string token)
|
||||
{
|
||||
@@ -232,7 +232,8 @@ namespace Discord.WebSocket
|
||||
ConnectionState = ConnectionState.Connected;
|
||||
await _gatewayLogger.InfoAsync("Connected").ConfigureAwait(false);
|
||||
|
||||
await ProcessUserDownloadsAsync(_downloadUsersFor.Select(x => GetGuild(x)).Where(x => x != null).ToImmutableArray()).ConfigureAwait(false);
|
||||
await ProcessUserDownloadsAsync(_downloadUsersFor.Select(x => GetGuild(x))
|
||||
.Where(x => x != null).ToImmutableArray()).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
27
src/Discord.Net.WebSocket/Net/DefaultUdpSocketProvider.cs
Normal file
27
src/Discord.Net.WebSocket/Net/DefaultUdpSocketProvider.cs
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user