using Serein.Library;
using Serein.Library.Entity;
using Serein.Library.Api;
using Serein.Library.Attributes;
using Serein.Library.Enums;
using Serein.Library.Network.WebSocketCommunication;
using System.Security.Cryptography.X509Certificates;
using Serein.NodeFlow;
using Serein.Library.Core.NodeFlow;
using Serein.Library.NodeFlow.Tool;
using Serein.Library.Utils;
using Serein.FlowRemoteManagement.Model;
namespace SereinFlowRemoteManagement
{
public enum FlowEnvCommand
{
A,
B,
C,
D
}
///
/// SereinFlow 远程管理模块
///
[DynamicFlow]
[AutoRegister]
[AutoSocketModule(ThemeKey ="theme",DataKey ="data")]
public class FlowRemoteManagement : FlowTrigger, ISocketHandleModule
{
#region 初始化
public Guid HandleGuid { get; } = new Guid();
private readonly FlowEnvironment environment;
public FlowRemoteManagement(IFlowEnvironment environment)
{
if(environment is FlowEnvironment env)
{
this.environment = env;
}
else
{
throw new Exception();
}
}
[NodeAction(NodeType.Init)]
public void Init(IDynamicContext context)
{
environment.IOC.Register();
}
[NodeAction(NodeType.Loading)]
public void Loading(IDynamicContext context)
{
environment.IOC.Run(async (socketServer) =>
{
socketServer.MsgHandleHelper.AddModule(this,
(ex, send) =>
{
send(new
{
code = 400,
ex = ex.Message
});
});
await socketServer.StartAsync("http://*:7525/");
});
SereinProjectData projectData = environment.SaveProject();
}
#endregion
#region 对外接口
///
/// 更改两个节点的连接关系
///
///
///
///
[AutoSocketHandle(ThemeValue = "ConnectionChange")]
public void ChangeNodeConnection(ConnectionInfoData nodeInfo, Func