Browse Source

Merge remote-tracking branch 'upstream/dev' into dev

pull/1043/head
Acid Chicken (硫酸鶏) 7 years ago
parent
commit
1ab9de2497
8 changed files with 43 additions and 29 deletions
  1. +3
    -2
      src/Discord.Net.Core/Discord.Net.Core.csproj
  2. +6
    -6
      src/Discord.Net.Core/Entities/Guilds/IVoiceRegion.cs
  3. +3
    -2
      src/Discord.Net.DebugTools/Discord.Net.DebugTools.csproj
  4. +5
    -5
      src/Discord.Net.Rest/API/Common/VoiceRegion.cs
  5. +3
    -2
      src/Discord.Net.Rest/Discord.Net.Rest.csproj
  6. +10
    -5
      src/Discord.Net.Rest/Entities/Guilds/RestVoiceRegion.cs
  7. +10
    -5
      src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs
  8. +3
    -2
      src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj

+ 3
- 2
src/Discord.Net.Core/Discord.Net.Core.csproj View File

@@ -4,11 +4,12 @@
<AssemblyName>Discord.Net.Core</AssemblyName>
<RootNamespace>Discord</RootNamespace>
<Description>The core components for the Discord.Net library.</Description>
<TargetFrameworks>net45;netstandard1.1;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net45;netstandard1.1;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.1;netstandard1.3</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
<PackageReference Include="System.Interactive.Async" Version="3.1.1" />
</ItemGroup>
</Project>
</Project>

+ 6
- 6
src/Discord.Net.Core/Entities/Guilds/IVoiceRegion.cs View File

@@ -1,4 +1,4 @@
namespace Discord
namespace Discord
{
public interface IVoiceRegion
{
@@ -10,9 +10,9 @@
bool IsVip { get; }
/// <summary> Returns true if this voice region is the closest to your machine. </summary>
bool IsOptimal { get; }
/// <summary> Gets an example hostname for this voice region. </summary>
string SampleHostname { get; }
/// <summary> Gets an example port for this voice region. </summary>
int SamplePort { get; }
/// <summary> Returns true if this is a deprecated voice region (avoid switching to these). </summary>
bool IsDeprecated { get; }
/// <summary> Returns true if this is a custom voice region (used for events/etc) </summary>
bool IsCustom { get; }
}
}
}

+ 3
- 2
src/Discord.Net.DebugTools/Discord.Net.DebugTools.csproj View File

@@ -4,9 +4,10 @@
<AssemblyName>Discord.Net.DebugTools</AssemblyName>
<RootNamespace>Discord</RootNamespace>
<Description>A Discord.Net extension adding some helper classes for diagnosing issues.</Description>
<TargetFrameworks>net45;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net45;netstandard1.3</TargetFrameworks>
<TargetFramework Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.3</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />
</ItemGroup>
</Project>
</Project>

+ 5
- 5
src/Discord.Net.Rest/API/Common/VoiceRegion.cs View File

@@ -1,4 +1,4 @@
#pragma warning disable CS1591
#pragma warning disable CS1591
using Newtonsoft.Json;

namespace Discord.API
@@ -13,9 +13,9 @@ namespace Discord.API
public bool IsVip { get; set; }
[JsonProperty("optimal")]
public bool IsOptimal { get; set; }
[JsonProperty("sample_hostname")]
public string SampleHostname { get; set; }
[JsonProperty("sample_port")]
public int SamplePort { get; set; }
[JsonProperty("deprecated")]
public bool IsDeprecated { get; set; }
[JsonProperty("custom")]
public bool IsCustom { get; set; }
}
}

+ 3
- 2
src/Discord.Net.Rest/Discord.Net.Rest.csproj View File

@@ -4,7 +4,8 @@
<AssemblyName>Discord.Net.Rest</AssemblyName>
<RootNamespace>Discord.Rest</RootNamespace>
<Description>A core Discord.Net library containing the REST client and models.</Description>
<TargetFrameworks>net45;netstandard1.1;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net45;netstandard1.1;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.1;netstandard1.3</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />
@@ -16,4 +17,4 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System.Net.Http" />
</ItemGroup>
</Project>
</Project>

+ 10
- 5
src/Discord.Net.Rest/Entities/Guilds/RestVoiceRegion.cs View File

@@ -1,4 +1,4 @@
using Discord.Rest;
using Discord.Rest;
using System.Diagnostics;
using Model = Discord.API.VoiceRegion;

@@ -7,11 +7,16 @@ namespace Discord
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RestVoiceRegion : RestEntity<string>, IVoiceRegion
{
/// <inheritdoc />
public string Name { get; private set; }
/// <inheritdoc />
public bool IsVip { get; private set; }
/// <inheritdoc />
public bool IsOptimal { get; private set; }
public string SampleHostname { get; private set; }
public int SamplePort { get; private set; }
/// <inheritdoc />
public bool IsDeprecated { get; private set; }
/// <inheritdoc />
public bool IsCustom { get; private set; }

internal RestVoiceRegion(BaseDiscordClient client, string id)
: base(client, id)
@@ -28,8 +33,8 @@ namespace Discord
Name = model.Name;
IsVip = model.IsVip;
IsOptimal = model.IsOptimal;
SampleHostname = model.SampleHostname;
SamplePort = model.SamplePort;
IsDeprecated = model.IsDeprecated;
IsCustom = model.IsCustom;
}

public override string ToString() => Name;


+ 10
- 5
src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs View File

@@ -163,7 +163,7 @@ namespace Discord.Net.Queue
if (!isRateLimited)
throw new TimeoutException();
else
throw new RateLimitedException(request);
ThrowRetryLimit(request);
}

lock (_lock)
@@ -181,13 +181,12 @@ namespace Discord.Net.Queue
await _queue.RaiseRateLimitTriggered(Id, null).ConfigureAwait(false);
}

if ((request.Options.RetryMode & RetryMode.RetryRatelimit) == 0)
throw new RateLimitedException(request);
ThrowRetryLimit(request);

if (resetAt.HasValue)
{
if (resetAt > timeoutAt)
throw new RateLimitedException(request);
ThrowRetryLimit(request);
int millis = (int)Math.Ceiling((resetAt.Value - DateTimeOffset.UtcNow).TotalMilliseconds);
#if DEBUG_LIMITS
Debug.WriteLine($"[{id}] Sleeping {millis} ms (Pre-emptive)");
@@ -198,7 +197,7 @@ namespace Discord.Net.Queue
else
{
if ((timeoutAt.Value - DateTimeOffset.UtcNow).TotalMilliseconds < 500.0)
throw new RateLimitedException(request);
ThrowRetryLimit(request);
#if DEBUG_LIMITS
Debug.WriteLine($"[{id}] Sleeping 500* ms (Pre-emptive)");
#endif
@@ -309,5 +308,11 @@ namespace Discord.Net.Queue
}
}
}

private void ThrowRetryLimit(RestRequest request)
{
if ((request.Options.RetryMode & RetryMode.RetryRatelimit) == 0)
throw new RateLimitedException(request);
}
}
}

+ 3
- 2
src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj View File

@@ -4,7 +4,8 @@
<AssemblyName>Discord.Net.WebSocket</AssemblyName>
<RootNamespace>Discord.WebSocket</RootNamespace>
<Description>A core Discord.Net library containing the WebSocket client and models.</Description>
<TargetFrameworks>net45;netstandard1.1;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net45;netstandard1.1;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.1;netstandard1.3</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
@@ -14,4 +15,4 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.1" />
</ItemGroup>
</Project>
</Project>

Loading…
Cancel
Save