Add logic for inventory rate-limiting

This commit is contained in:
JustArchi
2017-09-18 16:40:01 +02:00
parent c41a91dd51
commit e574e6f9bf
3 changed files with 80 additions and 16 deletions

View File

@@ -156,6 +156,34 @@ namespace ArchiSteamFarm {
}
}
internal async Task<(bool Success, T Result)> UrlGetToJsonResultWithSuccessRetry<T>(string request, string referer = null) {
if (string.IsNullOrEmpty(request)) {
ArchiLogger.LogNullError(nameof(request));
return default;
}
string json = await UrlGetToContentRetry(request, referer).ConfigureAwait(false);
if (string.IsNullOrEmpty(json)) {
return default;
}
T result;
try {
result = JsonConvert.DeserializeObject<T>(json);
} catch (JsonException e) {
ArchiLogger.LogGenericException(e);
if (Debugging.IsUserDebugging) {
ArchiLogger.LogGenericDebug(string.Format(Strings.Content, json));
}
return default;
}
return (true, result);
}
internal async Task<XmlDocument> UrlGetToXMLRetry(string request, string referer = null) {
if (string.IsNullOrEmpty(request)) {
ArchiLogger.LogNullError(nameof(request));