1 Commits
Author SHA1 Message Date
cneicy b1c42ea4ab fix(bridge): release command service registration ownership
Publish NuGet packages / publish (push) Successful in 4m53s
Publish UPM package / publish (push) Successful in 2s
2026-09-29 10:14:40 +08:00
4 changed files with 23 additions and 13 deletions
@@ -5,16 +5,16 @@
<AssemblyName>ShrinkCommand.Integration.Network</AssemblyName> <AssemblyName>ShrinkCommand.Integration.Network</AssemblyName>
<RootNamespace>ShrinkCommand.Integration</RootNamespace> <RootNamespace>ShrinkCommand.Integration</RootNamespace>
<PackageId>ShrinkSDK.Command.Integration.Network</PackageId> <PackageId>ShrinkSDK.Command.Integration.Network</PackageId>
<Version>0.2.0</Version> <Version>0.2.5</Version>
<Description>ShrinkCommand and Network RPC integration.</Description> <Description>ShrinkCommand and Network RPC integration.</Description>
<ShrinkCodeGenEnabled>true</ShrinkCodeGenEnabled> <ShrinkCodeGenEnabled>true</ShrinkCodeGenEnabled>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\*.cs" /> <Compile Include="..\*.cs" />
<PackageReference Include="ShrinkSDK.Runtime.Abstractions" Version="0.1.0" /> <PackageReference Include="ShrinkSDK.Runtime.Abstractions" Version="0.1.0" />
<PackageReference Include="ShrinkSDK.Context.Core" Version="0.2.0" /> <PackageReference Include="ShrinkSDK.Context.Core" Version="0.3.0" />
<PackageReference Include="ShrinkSDK.Command" Version="0.3.0" /> <PackageReference Include="ShrinkSDK.Command" Version="0.4.2" />
<PackageReference Include="ShrinkSDK.Network" Version="0.3.0" /> <PackageReference Include="ShrinkSDK.Network" Version="0.4.2" />
<PackageReference Include="ShrinkSDK.CodeGen" Version="0.1.0" PrivateAssets="compile;runtime;contentfiles;native" /> <PackageReference Include="ShrinkSDK.CodeGen" Version="0.2.0" PrivateAssets="compile;runtime;contentfiles;native" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+10
View File
@@ -24,3 +24,13 @@ networkService.UseCommandBridge(commandService);
```csharp ```csharp
var response = await session.ExecuteCommandAsync("help"); var response = await session.ExecuteCommandAsync("help");
``` ```
## 可复用能力
<!-- shrink:capabilities -->
Capability: 通过 RPC 执行命令,将远端会话映射为命令来源
Aliases: 远程命令 rpc command 控制台
Limits: 仍需校验来源和权限;不能将任意 RPC 当作管理员授权
Extension: 桥接配置与会话来源映射
Evidence: [ShrinkNetworkCommandBridge](ShrinkNetworkCommandBridge.cs)
<!-- /shrink:capabilities -->
+4 -4
View File
@@ -1,7 +1,7 @@
#nullable enable #nullable enable
using System; using System;
using System.Collections.Generic; using System.Runtime.CompilerServices;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
using ShrinkNetwork; using ShrinkNetwork;
@@ -12,7 +12,7 @@ namespace ShrinkCommand.Integration
public const string ExecuteRoute = "command/execute"; public const string ExecuteRoute = "command/execute";
private static readonly object SyncRoot = new(); 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( public static void RegisterService(
ShrinkNetworkService networkService, ShrinkNetworkService networkService,
@@ -26,9 +26,9 @@ namespace ShrinkCommand.Integration
lock (SyncRoot) lock (SyncRoot)
{ {
if (RegisteredServices.Contains(networkService)) if (RegisteredServices.TryGetValue(networkService, out _))
return; return;
RegisteredServices.Add(networkService); RegisteredServices.Add(networkService, new object());
} }
options ??= new ShrinkNetworkCommandBridgeOptions(); options ??= new ShrinkNetworkCommandBridgeOptions();
+4 -4
View File
@@ -1,13 +1,13 @@
{ {
"name": "com.cneicy.shrink-command-integration-network", "name": "com.cneicy.shrink-command-integration-network",
"version": "0.2.0", "version": "0.2.5",
"displayName": "ShrinkCommand - Network Integration", "displayName": "ShrinkCommand - Network Integration",
"description": "ShrinkCommand 与 ShrinkNetwork 的桥接层,允许远程会话通过 RPC 执行命令。", "description": "ShrinkCommand 与 ShrinkNetwork 的桥接层,允许远程会话通过 RPC 执行命令。",
"unity": "2022.3", "unity": "2022.3",
"dependencies": { "dependencies": {
"com.cneicy.shrink-command": "0.3.0", "com.cneicy.shrink-command": "0.4.2",
"com.cneicy.shrink-network": "0.3.0", "com.cneicy.shrink-network": "0.4.2",
"com.cneicy.shrink-context-core": "0.2.0" "com.cneicy.shrink-context-core": "0.3.0"
}, },
"keywords": [ "keywords": [
"command", "command",