Browse Source

Also try to resume on missed heartbeats

pull/1500/head
FiniteReality 5 years ago
parent
commit
8dbd4db2ed
2 changed files with 8 additions and 5 deletions
  1. +2
    -2
      src/Discord.Net.WebSocket/DiscordSocketClient.cs
  2. +6
    -3
      src/Discord.Net.WebSocket/GatewayReconnectException.cs

+ 2
- 2
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -511,7 +511,7 @@ namespace Discord.WebSocket
case GatewayOpCode.Reconnect:
{
await _gatewayLogger.DebugAsync("Received Reconnect").ConfigureAwait(false);
_connection.Error(new GatewayReconnectException());
_connection.Error(new GatewayReconnectException("Server requested a reconnect"));
}
break;
case GatewayOpCode.Dispatch:
@@ -1689,7 +1689,7 @@ namespace Discord.WebSocket
{
if (ConnectionState == ConnectionState.Connected && (_guildDownloadTask?.IsCompleted ?? true))
{
_connection.Error(new Exception("Server missed last heartbeat"));
_connection.Error(new GatewayReconnectException("Server missed last heartbeat"));
return;
}
}


+ 6
- 3
src/Discord.Net.WebSocket/GatewayReconnectException.cs View File

@@ -3,7 +3,7 @@ using System;
namespace Discord.WebSocket
{
/// <summary>
/// An exception thrown when Discord requests the gateway client to
/// An exception thrown when the gateway client has been requested to
/// reconnect.
/// </summary>
public class GatewayReconnectException : Exception
@@ -12,8 +12,11 @@ namespace Discord.WebSocket
/// Creates a new instance of the
/// <see cref="GatewayReconnectException"/> type.
/// </summary>
public GatewayReconnectException()
: base("Server requested a reconnect")
/// <param name="message">
/// The reason why the gateway has been requested to reconnect.
/// </param>
public GatewayReconnectException(string message)
: base(message)
{ }
}
}

Loading…
Cancel
Save