public async Task <List <LiteGraph.Node> > GetNodesForPanel(string panelId) { return(await Task.Run(() => { if (engine == null) { return null; } if (panelId == null) { panelId = MAIN_PANEL_ID; } lock (engine.nodesLock) { List <Nodes.Node> nodes = engine.GetNodes(); if (nodes == null || !nodes.Any()) { return null; } return ( from node in nodes where node.PanelId == panelId select ConvertNodeToLiteGraphNode(node)).ToList(); } })); }
public async Task <int> SetValue(string value, string channel, string password) { NodesEngine engine = SystemController.nodesEngine; if (password == "") { password = null; } return(await Task.Run(() => { if (engine == null) { return 2; } List <ConnectionRemoteReceiverNode> receivers; lock (engine.nodesLock) receivers = engine.GetNodes() .OfType <ConnectionRemoteReceiverNode>() .Where(x => x.GetChannel().ToString() == channel) .ToList(); if (!receivers.Any()) { engine.LogNodesError( $"Received a value for Remote Receiver, but no receivers with channel [{channel}]"); return 2; } var ip = Context.Request.HttpContext.Connection.RemoteIpAddress; string address = ip?.ToString(); bool received = false; foreach (var receiver in receivers) { if (receiver.ReceiveValue(value, channel, password, address)) { received = true; } } return received ? 0 : 1; })); }