feat(cordis): 接入上下文组合与模组事务热替换

This commit is contained in:
2026-08-16 23:20:40 +08:00
commit ad256f109b
676 changed files with 52168 additions and 0 deletions
@@ -0,0 +1,52 @@
#nullable enable
using System;
using Cysharp.Threading.Tasks;
using ShrinkNetwork;
namespace ShrinkCommand.Integration
{
public static class ShrinkNetworkCommandBridgeExtensions
{
public static ShrinkNetworkService UseCommandBridge(
this ShrinkNetworkService networkService,
ShrinkCommandService commandService,
ShrinkNetworkCommandBridgeOptions? options = null)
{
if (networkService == null)
throw new ArgumentNullException(nameof(networkService));
if (commandService == null)
throw new ArgumentNullException(nameof(commandService));
ShrinkNetworkCommandBridge.RegisterService(networkService, commandService, options);
return networkService;
}
public static async UniTask<ShrinkNetworkCommandResponse> ExecuteCommandAsync(
this ShrinkNetworkSession session,
string commandLine,
string? serviceName = null,
string? clientLabel = null,
ShrinkRpcCallOptions? options = null)
{
if (session == null)
throw new ArgumentNullException(nameof(session));
ShrinkNetworkCommandBridge.EnsureMessagesRegistered(session.Service);
return await session.RpcAsync<ShrinkNetworkCommandRequest, ShrinkNetworkCommandResponse>(
new ShrinkNetworkCommandRequest
{
ServiceName = string.IsNullOrWhiteSpace(serviceName)
? ShrinkCommandConstants.DefaultServiceName
: serviceName.Trim(),
CommandLine = commandLine ?? string.Empty,
ClientLabel = clientLabel ?? string.Empty
},
options ?? new ShrinkRpcCallOptions
{
TimeoutMs = 5000,
DebugLabel = "RemoteCommand"
});
}
}
}