Dont crash the heartbeat task if unable to send a heartbeat

This commit is contained in:
RogueException
2016-08-23 06:12:59 -03:00
parent f6d8659a2e
commit 83aca9acef

View File

@@ -1513,7 +1513,6 @@ namespace Discord.WebSocket
private async Task RunHeartbeatAsync(int intervalMillis, CancellationToken cancelToken, ILogger logger)
{
//Clean this up when Discord's session patch is live
try
{
await logger.DebugAsync("Heartbeat Started").ConfigureAwait(false);
@@ -1529,8 +1528,15 @@ namespace Discord.WebSocket
}
}
await ApiClient.SendHeartbeatAsync(_lastSeq).ConfigureAwait(false);
_heartbeatTime = Environment.TickCount;
try
{
await ApiClient.SendHeartbeatAsync(_lastSeq).ConfigureAwait(false);
_heartbeatTime = Environment.TickCount;
}
catch (Exception ex)
{
await logger.WarningAsync("Heartbeat Errored", ex).ConfigureAwait(false);
}
await Task.Delay(intervalMillis, cancelToken).ConfigureAwait(false);
}