using Serein.Library;
using Serein.Library.Api;
using Serein.Library.Network.WebSocketCommunication;
using System.Security.Cryptography.X509Certificates;
using Serein.NodeFlow;
using Serein.Library.Core.NodeFlow;
using Serein.Library.Utils;
using Serein.FlowRemoteManagement.Model;
using System.Reflection;
using Serein.Library.FlowNode;
namespace SereinFlowRemoteManagement
{
///
/// SereinFlow 远程控制模块
///
[DynamicFlow]
[AutoRegister]
[AutoSocketModule(ThemeKey ="theme",DataKey ="data")]
public class SereinFlowRemoteControl : ISocketHandleModule
{
public int ServerPort { get; set; } = 7525;
#region 初始化服务端
public Guid HandleGuid { get; } = new Guid();
private readonly IFlowEnvironment environment;
public SereinFlowRemoteControl(IFlowEnvironment environment)
{
this.environment = environment;
}
[NodeAction(NodeType.Init)]
public void Init(IDynamicContext context)
{
environment.IOC.Register();
}
[NodeAction(NodeType.Loading)]
public async Task Loading(IDynamicContext context)
{
environment.IOC.Run(async (socketServer) =>
{
socketServer.MsgHandleHelper.AddModule(this,
(ex, send) =>
{
send(new
{
code = 400,
ex = ex.Message
});
});
await Console.Out.WriteLineAsync("启动远程管理模块");
await socketServer.StartAsync($"http://*:{ServerPort}/");
});
SereinProjectData projectData = await environment.GetProjectInfoAsync();
}
#endregion
#region 流程运行接口
///
/// 连接到运行环境,获取当前的节点信息
///
///
///
[AutoSocketHandle]
public async Task