mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Fix logging in when steam API is unavailable
Or at least part of it...
This commit is contained in:
@@ -1596,7 +1596,7 @@ namespace ArchiSteamFarm {
|
||||
ArchiHandler.PlayGames(BotConfig.GamesPlayedWhileIdle, BotConfig.CustomGamePlayedWhileIdle);
|
||||
}
|
||||
|
||||
private async void OnConnected(SteamClient.ConnectedCallback callback) {
|
||||
private void OnConnected(SteamClient.ConnectedCallback callback) {
|
||||
if (callback == null) {
|
||||
Logging.LogNullError(nameof(callback), BotName);
|
||||
return;
|
||||
@@ -1636,7 +1636,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
// If we have ASF 2FA enabled, we can always provide TwoFactorCode, and save a request
|
||||
if (BotDatabase.MobileAuthenticator != null) {
|
||||
TwoFactorCode = await BotDatabase.MobileAuthenticator.GenerateToken().ConfigureAwait(false);
|
||||
TwoFactorCode = BotDatabase.MobileAuthenticator.GenerateTokenImmediately();
|
||||
}
|
||||
|
||||
SteamUser.LogOnDetails logOnDetails = new SteamUser.LogOnDetails {
|
||||
|
||||
@@ -195,6 +195,16 @@ namespace ArchiSteamFarm {
|
||||
return null;
|
||||
}
|
||||
|
||||
internal string GenerateTokenImmediately() {
|
||||
uint time = GetSteamTimeImmediately();
|
||||
if (time != 0) {
|
||||
return GenerateTokenForTime(time);
|
||||
}
|
||||
|
||||
Logging.LogNullError(nameof(time), Bot.BotName);
|
||||
return null;
|
||||
}
|
||||
|
||||
internal async Task<HashSet<Confirmation>> GetConfirmations() {
|
||||
if (!HasCorrectDeviceID) {
|
||||
Logging.LogGenericWarning("Can't execute properly due to invalid DeviceID!", Bot.BotName);
|
||||
@@ -274,16 +284,32 @@ namespace ArchiSteamFarm {
|
||||
return (uint) (Utilities.GetUnixTime() + SteamTimeDifference.GetValueOrDefault());
|
||||
}
|
||||
|
||||
await TimeSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
if (!await TimeSemaphore.WaitAsync(0).ConfigureAwait(false)) {
|
||||
return (uint) (Utilities.GetUnixTime() + SteamTimeDifference.GetValueOrDefault());
|
||||
}
|
||||
|
||||
try {
|
||||
if (SteamTimeDifference.HasValue) {
|
||||
return (uint) (Utilities.GetUnixTime() + SteamTimeDifference.GetValueOrDefault());
|
||||
}
|
||||
|
||||
if (!SteamTimeDifference.HasValue) {
|
||||
uint serverTime = Bot.ArchiWebHandler.GetServerTime();
|
||||
if (serverTime != 0) {
|
||||
SteamTimeDifference = (short) (serverTime - Utilities.GetUnixTime());
|
||||
}
|
||||
|
||||
return (uint) (Utilities.GetUnixTime() + SteamTimeDifference.GetValueOrDefault());
|
||||
} finally {
|
||||
TimeSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private uint GetSteamTimeImmediately() {
|
||||
if (!SteamTimeDifference.HasValue) {
|
||||
// We must return time immediately, schedule update in the background and proceed
|
||||
GetSteamTime().Forget();
|
||||
}
|
||||
|
||||
TimeSemaphore.Release();
|
||||
return (uint) (Utilities.GetUnixTime() + SteamTimeDifference.GetValueOrDefault());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user