Revert "Fix logging in when steam API is unavailable"

This reverts commit 5a267eb225.
This commit is contained in:
JustArchi
2016-09-16 22:46:10 +02:00
parent 5a267eb225
commit feb80fbf49
2 changed files with 5 additions and 31 deletions

View File

@@ -1596,7 +1596,7 @@ namespace ArchiSteamFarm {
ArchiHandler.PlayGames(BotConfig.GamesPlayedWhileIdle, BotConfig.CustomGamePlayedWhileIdle); ArchiHandler.PlayGames(BotConfig.GamesPlayedWhileIdle, BotConfig.CustomGamePlayedWhileIdle);
} }
private void OnConnected(SteamClient.ConnectedCallback callback) { private async void OnConnected(SteamClient.ConnectedCallback callback) {
if (callback == null) { if (callback == null) {
Logging.LogNullError(nameof(callback), BotName); Logging.LogNullError(nameof(callback), BotName);
return; return;
@@ -1636,7 +1636,7 @@ namespace ArchiSteamFarm {
// If we have ASF 2FA enabled, we can always provide TwoFactorCode, and save a request // If we have ASF 2FA enabled, we can always provide TwoFactorCode, and save a request
if (BotDatabase.MobileAuthenticator != null) { if (BotDatabase.MobileAuthenticator != null) {
TwoFactorCode = BotDatabase.MobileAuthenticator.GenerateTokenImmediately(); TwoFactorCode = await BotDatabase.MobileAuthenticator.GenerateToken().ConfigureAwait(false);
} }
SteamUser.LogOnDetails logOnDetails = new SteamUser.LogOnDetails { SteamUser.LogOnDetails logOnDetails = new SteamUser.LogOnDetails {

View File

@@ -195,16 +195,6 @@ namespace ArchiSteamFarm {
return null; 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() { internal async Task<HashSet<Confirmation>> GetConfirmations() {
if (!HasCorrectDeviceID) { if (!HasCorrectDeviceID) {
Logging.LogGenericWarning("Can't execute properly due to invalid DeviceID!", Bot.BotName); Logging.LogGenericWarning("Can't execute properly due to invalid DeviceID!", Bot.BotName);
@@ -284,32 +274,16 @@ namespace ArchiSteamFarm {
return (uint) (Utilities.GetUnixTime() + SteamTimeDifference.GetValueOrDefault()); return (uint) (Utilities.GetUnixTime() + SteamTimeDifference.GetValueOrDefault());
} }
if (!await TimeSemaphore.WaitAsync(0).ConfigureAwait(false)) { await TimeSemaphore.WaitAsync().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(); uint serverTime = Bot.ArchiWebHandler.GetServerTime();
if (serverTime != 0) { if (serverTime != 0) {
SteamTimeDifference = (short) (serverTime - Utilities.GetUnixTime()); 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()); return (uint) (Utilities.GetUnixTime() + SteamTimeDifference.GetValueOrDefault());
} }