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

@@ -1,20 +0,0 @@
#pragma warning disable CS1591
using Newtonsoft.Json;
using System;
namespace Discord.API.Rpc
{
internal class RpcFrame
{
[JsonProperty("cmd")]
public string Cmd { get; set; }
[JsonProperty("nonce")]
public Optional<Guid?> Nonce { get; set; }
[JsonProperty("evt")]
public Optional<string> Event { get; set; }
[JsonProperty("data")]
public Optional<object> Data { get; set; }
[JsonProperty("args")]
public object Args { get; set; }
}
}

View File

@@ -1,17 +0,0 @@
#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; }
}
}

View File

@@ -10,6 +10,6 @@ namespace Discord.Rest
internal const int WebSocketQueueInterval = 100;
/// <summary> Gets or sets the provider used to generate new REST connections. </summary>
public RestClientProvider RestClientProvider { get; set; } = url => new DefaultRestClient(url);
public RestClientProvider RestClientProvider { get; set; } = DefaultRestClientProvider.Instance;
}
}

View File

@@ -0,0 +1,19 @@
using System;
namespace Discord.Net.Rest
{
public static class DefaultRestClientProvider
{
public static readonly RestClientProvider Instance = url =>
{
try
{
return new DefaultRestClient(url);
}
catch (PlatformNotSupportedException ex)
{
throw new PlatformNotSupportedException("The default RestClientProvider is not supported on this platform.", ex);
}
};
}
}