handle reconnects more gracefully

pull/401/head
Yaakov 3 years ago
parent 8d6c09e779
commit c36ddcc065

@ -482,6 +482,12 @@ namespace DepotDownloader
Console.WriteLine(" Done!"); Console.WriteLine(" Done!");
bConnecting = false; bConnecting = false;
bConnected = true; bConnected = true;
// Update our tracking so that we don't time out, even if we need to reconnect multiple times,
// e.g. if the authentication phase takes a while and therefore multiple connections.
connectTime = DateTime.Now;
connectionBackoff = 0;
if (!authenticatedUser) if (!authenticatedUser)
{ {
Console.Write("Logging anonymously into Steam3..."); Console.Write("Logging anonymously into Steam3...");
@ -515,10 +521,15 @@ namespace DepotDownloader
AccountSettingsStore.Instance.LoginTokens[result.AccountName] = result.RefreshToken; AccountSettingsStore.Instance.LoginTokens[result.AccountName] = result.RefreshToken;
AccountSettingsStore.Save(); AccountSettingsStore.Save();
} }
catch (TaskCanceledException)
{
return;
}
catch (Exception ex) catch (Exception ex)
{ {
Console.Error.WriteLine("Failed to authenticate with Steam: " + ex.Message); Console.Error.WriteLine("Failed to authenticate with Steam: " + ex.Message);
Abort(false); Abort(false);
return;
} }
} }
else if (ContentDownloader.Config.UseQrCode) else if (ContentDownloader.Config.UseQrCode)
@ -554,10 +565,15 @@ namespace DepotDownloader
AccountSettingsStore.Instance.LoginTokens[result.AccountName] = result.RefreshToken; AccountSettingsStore.Instance.LoginTokens[result.AccountName] = result.RefreshToken;
AccountSettingsStore.Save(); AccountSettingsStore.Save();
} }
catch (TaskCanceledException)
{
return;
}
catch (Exception ex) catch (Exception ex)
{ {
Console.Error.WriteLine("Failed to authenticate with Steam: " + ex.Message); Console.Error.WriteLine("Failed to authenticate with Steam: " + ex.Message);
Abort(false); Abort(false);
return;
} }
} }
@ -569,6 +585,8 @@ namespace DepotDownloader
{ {
bDidDisconnect = true; bDidDisconnect = true;
DebugLog.WriteLine(nameof(Steam3Session), $"Disconnected: bIsConnectionRecovery = {bIsConnectionRecovery}, UserInitiated = {disconnected.UserInitiated}, bExpectingDisconnectRemote = {bExpectingDisconnectRemote}");
// When recovering the connection, we want to reconnect even if the remote disconnects us // When recovering the connection, we want to reconnect even if the remote disconnects us
if (!bIsConnectionRecovery && (disconnected.UserInitiated || bExpectingDisconnectRemote)) if (!bIsConnectionRecovery && (disconnected.UserInitiated || bExpectingDisconnectRemote))
{ {

Loading…
Cancel
Save