Try to address #3362

This commit is contained in:
Łukasz Domeradzki
2024-12-17 23:59:32 +01:00
parent dd7ae5801d
commit 054a317777
3 changed files with 102 additions and 91 deletions

View File

@@ -187,6 +187,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToConstant_002ELocal/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToExpressionBodyWhenPossible/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertToLambdaExpressionWhenPossible/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=DuplicatedSwitchSectionBodies/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=DuplicateResource/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceDoWhileStatementBraces/@EntryIndexedValue">WARNING</s:String>

View File

@@ -2101,6 +2101,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
}
private void DisposeShared() {
ArchiHandler.Dispose();
ArchiWebHandler.Dispose();
BotDatabase.Dispose();
ConnectionSemaphore.Dispose();

View File

@@ -25,6 +25,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Localization;
@@ -49,11 +50,11 @@ using EPersonaStateFlag = SteamKit2.EPersonaStateFlag;
namespace ArchiSteamFarm.Steam.Integration;
public sealed class ArchiHandler : ClientMsgHandler {
public sealed class ArchiHandler : ClientMsgHandler, IDisposable {
internal const byte MaxGamesPlayedConcurrently = 32; // This is limit introduced by Steam Network
private readonly ArchiLogger ArchiLogger;
private readonly SemaphoreSlim InventorySemaphore = new(1, 1);
private readonly AccountPrivateApps UnifiedAccountPrivateApps;
private readonly ChatRoom UnifiedChatRoomService;
private readonly ClanChatRooms UnifiedClanChatRoomsService;
@@ -87,6 +88,8 @@ public sealed class ArchiHandler : ClientMsgHandler {
UnifiedTwoFactorService = steamUnifiedMessages.CreateService<TwoFactor>();
}
public void Dispose() => InventorySemaphore.Dispose();
[PublicAPI]
public async Task<bool> AddFriend(ulong steamID) {
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
@@ -208,6 +211,9 @@ public sealed class ArchiHandler : ClientMsgHandler {
Dictionary<(ulong ClassID, ulong InstanceID), InventoryDescription>? descriptions = null;
await InventorySemaphore.WaitAsync().ConfigureAwait(false);
try {
while (true) {
SteamUnifiedMessages.ServiceMethodResponse<CEcon_GetInventoryItemsWithDescriptions_Response>? response = null;
@@ -314,6 +320,9 @@ public sealed class ArchiHandler : ClientMsgHandler {
request.start_assetid = response.Body.last_assetid;
}
} finally {
InventorySemaphore.Release();
}
}
[PublicAPI]