public RenderNode AddNode(RenderNode node) { RenderNode existing = GetNodeByName(node.Name); if (string.IsNullOrEmpty(node.Name)) { throw new ArgumentException("Node needs a name"); } if (string.IsNullOrEmpty(node.Address)) { throw new ArgumentException("Node needs an address"); } if (existing != null) { throw new ArgumentException($"Already have a node with name {node.Name}"); } if (node.Name == LocalNodeName) { Nodes.Insert(0, node); } else { Nodes.Add(node); } OnNodeAdded?.Invoke(this, node); return(node); }
/// <summary> /// Disconnects a specific client by name /// </summary> public void Disconnect(string name) { RenderNode node = GetNodeByName(name); if (node == null) { throw new ArgumentException($"Node does not exist with name {name}"); } node.Disconnect(); }
public void RemoveNode(string name) { RenderNode node = GetNodeByName(name); if (node != null) { Nodes.Remove(node); node.Disconnect(); OnNodeRemoved?.Invoke(this, node); } }
/// <summary> /// Connect to a specific client by name /// </summary> public async Task <RenderNode> Connect(string name) { RenderNode node = GetNodeByName(name); if (node == null) { throw new ArgumentException($"Node does not exist with name {name}"); } await node.Connect(); return(node); }
/// <summary> /// Attempts to add a node that was auto-discovered if its not already in the list of rendernodes /// </summary> public RenderNode TryAddDiscoveryNode(string name, string address, int port) { string addressPort = $"{address}:{port}"; RenderNode existing = GetNodeByAddress($"{addressPort}"); if (existing != null) { return(existing); } return(AddNode(name, addressPort, RenderType.CPU)); }
/// <summary> /// Connect to a specifc client by name and prepare the Blender version /// </summary> public async Task <bool> ConnectAndPrepare(string name) { RenderNode node = await Connect(name); return((await node.PrepareVersion(Version))?.Success ?? false); }