From b1c42ea4ab37479b745fbeeb3d7f2a0ba752ca0a Mon Sep 17 00:00:00 2001 From: cneicy Date: Tue, 29 Sep 2026 10:14:40 +0800 Subject: [PATCH] fix(bridge): release command service registration ownership --- DotNet~/ShrinkSDK.Command.Integration.Network.csproj | 10 +++++----- README.md | 10 ++++++++++ ShrinkNetworkCommandBridge.cs | 8 ++++---- package.json | 8 ++++---- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/DotNet~/ShrinkSDK.Command.Integration.Network.csproj b/DotNet~/ShrinkSDK.Command.Integration.Network.csproj index 7e513c2..9030c27 100644 --- a/DotNet~/ShrinkSDK.Command.Integration.Network.csproj +++ b/DotNet~/ShrinkSDK.Command.Integration.Network.csproj @@ -5,16 +5,16 @@ ShrinkCommand.Integration.Network ShrinkCommand.Integration ShrinkSDK.Command.Integration.Network - 0.2.0 + 0.2.5 ShrinkCommand and Network RPC integration. true - - - - + + + + diff --git a/README.md b/README.md index 1e44c62..411154c 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,13 @@ networkService.UseCommandBridge(commandService); ```csharp var response = await session.ExecuteCommandAsync("help"); ``` + +## 可复用能力 + + +Capability: 通过 RPC 执行命令,将远端会话映射为命令来源 +Aliases: 远程命令 rpc command 控制台 +Limits: 仍需校验来源和权限;不能将任意 RPC 当作管理员授权 +Extension: 桥接配置与会话来源映射 +Evidence: [ShrinkNetworkCommandBridge](ShrinkNetworkCommandBridge.cs) + diff --git a/ShrinkNetworkCommandBridge.cs b/ShrinkNetworkCommandBridge.cs index b2f6d31..eef6f22 100644 --- a/ShrinkNetworkCommandBridge.cs +++ b/ShrinkNetworkCommandBridge.cs @@ -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 RegisteredServices = new(); + private static readonly ConditionalWeakTable 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(); diff --git a/package.json b/package.json index 08b3fa1..9d47bc5 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "com.cneicy.shrink-command-integration-network", - "version": "0.2.0", + "version": "0.2.5", "displayName": "ShrinkCommand - Network Integration", "description": "ShrinkCommand 与 ShrinkNetwork 的桥接层,允许远程会话通过 RPC 执行命令。", "unity": "2022.3", "dependencies": { - "com.cneicy.shrink-command": "0.3.0", - "com.cneicy.shrink-network": "0.3.0", - "com.cneicy.shrink-context-core": "0.2.0" + "com.cneicy.shrink-command": "0.4.2", + "com.cneicy.shrink-network": "0.4.2", + "com.cneicy.shrink-context-core": "0.3.0" }, "keywords": [ "command",