コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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();
        }
コード例 #3
0
        public void RemoveNode(string name)
        {
            RenderNode node = GetNodeByName(name);

            if (node != null)
            {
                Nodes.Remove(node);
                node.Disconnect();
                OnNodeRemoved?.Invoke(this, node);
            }
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        /// <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));
        }
コード例 #6
0
        /// <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);
        }