mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Misc
This commit is contained in:
@@ -79,7 +79,7 @@ namespace ArchiSteamFarm.Core {
|
||||
internal static ICrossProcessSemaphore? LoginRateLimitingSemaphore { get; private set; }
|
||||
internal static ICrossProcessSemaphore? LoginSemaphore { get; private set; }
|
||||
internal static ICrossProcessSemaphore? RateLimitingSemaphore { get; private set; }
|
||||
internal static ImmutableDictionary<Uri, (ICrossProcessSemaphore RateLimitingSemaphore, SemaphoreSlim? OpenConnectionsSemaphore)>? WebLimitingSemaphores { get; private set; }
|
||||
internal static ImmutableDictionary<Uri, (ICrossProcessSemaphore RateLimitingSemaphore, SemaphoreSlim OpenConnectionsSemaphore)>? WebLimitingSemaphores { get; private set; }
|
||||
|
||||
private static readonly SemaphoreSlim UpdateSemaphore = new(1, 1);
|
||||
|
||||
@@ -419,7 +419,7 @@ namespace ArchiSteamFarm.Core {
|
||||
LoginSemaphore ??= await PluginsCore.GetCrossProcessSemaphore(nameof(LoginSemaphore) + networkGroupText).ConfigureAwait(false);
|
||||
RateLimitingSemaphore ??= await PluginsCore.GetCrossProcessSemaphore(nameof(RateLimitingSemaphore) + networkGroupText).ConfigureAwait(false);
|
||||
|
||||
WebLimitingSemaphores ??= new Dictionary<Uri, (ICrossProcessSemaphore RateLimitingSemaphore, SemaphoreSlim? OpenConnectionsSemaphore)>(4) {
|
||||
WebLimitingSemaphores ??= new Dictionary<Uri, (ICrossProcessSemaphore RateLimitingSemaphore, SemaphoreSlim OpenConnectionsSemaphore)>(4) {
|
||||
{ ArchiWebHandler.SteamCommunityURL, (await PluginsCore.GetCrossProcessSemaphore(nameof(ArchiWebHandler) + networkGroupText + "-" + nameof(ArchiWebHandler.SteamCommunityURL)).ConfigureAwait(false), new SemaphoreSlim(WebBrowser.MaxConnections, WebBrowser.MaxConnections)) },
|
||||
{ ArchiWebHandler.SteamHelpURL, (await PluginsCore.GetCrossProcessSemaphore(nameof(ArchiWebHandler) + networkGroupText + "-" + nameof(ArchiWebHandler.SteamHelpURL)).ConfigureAwait(false), new SemaphoreSlim(WebBrowser.MaxConnections, WebBrowser.MaxConnections)) },
|
||||
{ ArchiWebHandler.SteamStoreURL, (await PluginsCore.GetCrossProcessSemaphore(nameof(ArchiWebHandler) + networkGroupText + "-" + nameof(ArchiWebHandler.SteamStoreURL)).ConfigureAwait(false), new SemaphoreSlim(WebBrowser.MaxConnections, WebBrowser.MaxConnections)) },
|
||||
|
||||
@@ -27,12 +27,12 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
[Route("Api/Storage")]
|
||||
[Route("Api/Storage/{key:required}")]
|
||||
public sealed class StorageController : ArchiController {
|
||||
/// <summary>
|
||||
/// Deletes entry under specified key from ASF's persistent KeyValue JSON storage.
|
||||
/// </summary>
|
||||
[HttpDelete("{key:required}")]
|
||||
[HttpDelete]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
public ActionResult<GenericResponse> StorageDelete(string key) {
|
||||
if (string.IsNullOrEmpty(key)) {
|
||||
@@ -51,7 +51,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
/// <summary>
|
||||
/// Loads entry under specified key from ASF's persistent KeyValue JSON storage.
|
||||
/// </summary>
|
||||
[HttpGet("{key:required}")]
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(GenericResponse<JToken>), (int) HttpStatusCode.OK)]
|
||||
public ActionResult<GenericResponse> StorageGet(string key) {
|
||||
if (string.IsNullOrEmpty(key)) {
|
||||
@@ -71,7 +71,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
/// Saves entry under specified key in ASF's persistent KeyValue JSON storage.
|
||||
/// </summary>
|
||||
[Consumes("application/json")]
|
||||
[HttpPost("{key:required}")]
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
|
||||
public ActionResult<GenericResponse> StoragePost(string key, [FromBody] JToken value) {
|
||||
if (string.IsNullOrEmpty(key)) {
|
||||
|
||||
@@ -1316,16 +1316,14 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
return await function().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (!ASF.WebLimitingSemaphores.TryGetValue(service, out (ICrossProcessSemaphore RateLimitingSemaphore, SemaphoreSlim? OpenConnectionsSemaphore) limiters)) {
|
||||
if (!ASF.WebLimitingSemaphores.TryGetValue(service, out (ICrossProcessSemaphore RateLimitingSemaphore, SemaphoreSlim OpenConnectionsSemaphore) limiters)) {
|
||||
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(service), service));
|
||||
|
||||
limiters.RateLimitingSemaphore = ASF.RateLimitingSemaphore;
|
||||
}
|
||||
|
||||
// Sending a request opens a new connection
|
||||
if (limiters.OpenConnectionsSemaphore != null) {
|
||||
await limiters.OpenConnectionsSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
}
|
||||
await limiters.OpenConnectionsSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
|
||||
try {
|
||||
// It also increases number of requests
|
||||
@@ -1342,7 +1340,7 @@ namespace ArchiSteamFarm.Steam.Integration {
|
||||
return await function().ConfigureAwait(false);
|
||||
} finally {
|
||||
// We release open connections semaphore only once we're indeed done sending a particular request
|
||||
limiters.OpenConnectionsSemaphore?.Release();
|
||||
limiters.OpenConnectionsSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user