fix(bridge): release command service registration ownership
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using ShrinkNetwork;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ShrinkCommand.Integration
|
||||
public const string ExecuteRoute = "command/execute";
|
||||
|
||||
private static readonly object SyncRoot = new();
|
||||
private static readonly HashSet<ShrinkNetworkService> RegisteredServices = new();
|
||||
private static readonly ConditionalWeakTable<ShrinkNetworkService, object> RegisteredServices = new();
|
||||
|
||||
public static void RegisterService(
|
||||
ShrinkNetworkService networkService,
|
||||
@@ -26,9 +26,9 @@ namespace ShrinkCommand.Integration
|
||||
|
||||
lock (SyncRoot)
|
||||
{
|
||||
if (RegisteredServices.Contains(networkService))
|
||||
if (RegisteredServices.TryGetValue(networkService, out _))
|
||||
return;
|
||||
RegisteredServices.Add(networkService);
|
||||
RegisteredServices.Add(networkService, new object());
|
||||
}
|
||||
|
||||
options ??= new ShrinkNetworkCommandBridgeOptions();
|
||||
|
||||
Reference in New Issue
Block a user