It also fixes V3.0.4.6 regression reported in http://steamcommunity.com/groups/ascfarm/discussions/1/1488866180608154465 - even though it's just a workaround for Steam Network issue.
This commit is contained in:
JustArchi
2017-11-26 19:08:48 +01:00
parent d75c67febf
commit 6a74084729
5 changed files with 32 additions and 40 deletions

View File

@@ -73,7 +73,7 @@ namespace ArchiSteamFarm {
Logger.Debug($"{previousMethodName}() {message}");
}
internal void LogGenericDebugException(Exception exception, [CallerMemberName] string previousMethodName = null) {
internal void LogGenericDebuggingException(Exception exception, [CallerMemberName] string previousMethodName = null) {
if (exception == null) {
LogNullError(nameof(exception));
return;

View File

@@ -203,7 +203,6 @@ namespace ArchiSteamFarm {
CallbackManager.Subscribe<SteamFriends.PersonaStateCallback>(OnPersonaState);
SteamUser = SteamClient.GetHandler<SteamUser>();
CallbackManager.Subscribe<SteamUser.AccountInfoCallback>(OnAccountInfo);
CallbackManager.Subscribe<SteamUser.LoggedOffCallback>(OnLoggedOff);
CallbackManager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedOn);
CallbackManager.Subscribe<SteamUser.LoginKeyCallback>(OnLoginKey);
@@ -1237,7 +1236,7 @@ namespace ArchiSteamFarm {
HeartBeatFailures = 0;
Statistics?.OnHeartBeat().Forget();
} catch (Exception e) {
ArchiLogger.LogGenericDebugException(e);
ArchiLogger.LogGenericDebuggingException(e);
if (!KeepRunning || !IsConnectedAndLoggedOn || (HeartBeatFailures == byte.MaxValue)) {
return;
@@ -1487,38 +1486,6 @@ namespace ArchiSteamFarm {
}).Forget();
}
private async void OnAccountInfo(SteamUser.AccountInfoCallback callback) {
if (callback == null) {
ArchiLogger.LogNullError(nameof(callback));
return;
}
ArchiHandler.RequestItemAnnouncements();
// Sometimes Steam won't send us our own PersonaStateCallback, so request it explicitly
RequestPersonaStateUpdate();
InitializeFamilySharing().Forget();
Statistics?.OnAccountInfo().Forget();
if (BotConfig.SteamMasterClanID != 0) {
Task.Run(async () => {
await ArchiWebHandler.JoinGroup(BotConfig.SteamMasterClanID).ConfigureAwait(false);
JoinMasterChat();
}).Forget();
}
if (BotConfig.FarmOffline) {
return;
}
try {
await SteamFriends.SetPersonaState(EPersonaState.Online);
} catch (Exception e) {
ArchiLogger.LogGenericDebugException(e);
}
}
private void OnChatInvite(SteamFriends.ChatInviteCallback callback) {
if ((callback?.ChatRoomID == null) || (callback.PatronID == null)) {
ArchiLogger.LogNullError(nameof(callback) + " || " + nameof(callback.ChatRoomID) + " || " + nameof(callback.PatronID));
@@ -1958,7 +1925,32 @@ namespace ArchiSteamFarm {
}
if (!await ArchiWebHandler.Init(callback.ClientSteamID, SteamClient.Universe, callback.WebAPIUserNonce, BotConfig.SteamParentalPIN, callback.VanityURL).ConfigureAwait(false)) {
await RefreshSession().ConfigureAwait(false);
if (!await RefreshSession().ConfigureAwait(false)) {
break;
}
}
ArchiHandler.RequestItemAnnouncements();
// Sometimes Steam won't send us our own PersonaStateCallback, so request it explicitly
RequestPersonaStateUpdate();
InitializeFamilySharing().Forget();
Statistics?.OnLoggedOn().Forget();
if (BotConfig.SteamMasterClanID != 0) {
Task.Run(async () => {
await ArchiWebHandler.JoinGroup(BotConfig.SteamMasterClanID).ConfigureAwait(false);
JoinMasterChat();
}).Forget();
}
if (!BotConfig.FarmOffline) {
try {
await SteamFriends.SetPersonaState(EPersonaState.Online);
} catch (Exception) {
// TODO: We intentionally ignore this exception since SteamFriends.SetPersonaState() task seems to always throw TaskCanceledException, https://github.com/SteamRE/SteamKit/issues/491
}
}
break;

View File

@@ -138,7 +138,7 @@ namespace ArchiSteamFarm {
context.Response.ContentLength64 = response.Length;
await context.Response.OutputStream.WriteAsync(response, 0, response.Length).ConfigureAwait(false);
} catch (Exception e) {
ASF.ArchiLogger.LogGenericDebugException(e);
ASF.ArchiLogger.LogGenericDebuggingException(e);
}
}

View File

@@ -48,8 +48,6 @@ namespace ArchiSteamFarm {
public void Dispose() => RequestsSemaphore.Dispose();
internal async Task OnAccountInfo() => await Bot.ArchiWebHandler.JoinGroup(SharedInfo.ASFGroupSteamID).ConfigureAwait(false);
internal async Task OnHeartBeat() {
// Request persona update if needed
if ((DateTime.UtcNow > LastPersonaStateRequest.AddHours(MinPersonaStateTTL)) && (DateTime.UtcNow > LastAnnouncementCheck.AddHours(MinAnnouncementCheckTTL))) {
@@ -83,6 +81,8 @@ namespace ArchiSteamFarm {
}
}
internal async Task OnLoggedOn() => await Bot.ArchiWebHandler.JoinGroup(SharedInfo.ASFGroupSteamID).ConfigureAwait(false);
internal async Task OnPersonaState(SteamFriends.PersonaStateCallback callback) {
if (callback == null) {
ASF.ArchiLogger.LogNullError(nameof(callback));

View File

@@ -470,7 +470,7 @@ namespace ArchiSteamFarm {
try {
responseMessage = await HttpClient.SendAsync(requestMessage).ConfigureAwait(false);
} catch (Exception e) {
ArchiLogger.LogGenericDebugException(e);
ArchiLogger.LogGenericDebuggingException(e);
return null;
}
}