/// <summary>
        /// Stop bracer task.
        /// When you override this method in derived class, remember to call basic class method first.
        /// </summary>
        protected virtual void StopBracerTask()
        {
            BracerNode = new NodeHandle();

            if (_bracerCotask != null)
            {
                _bracerCotask.Dispose();
                _bracerCotask = null;

                BracerStateChanged.Invoke(BracerState.Disconnected);
            }
        }
        private void OnDestroy()
        {
            if (_bracerCotask != null)
            {
                _bracerCotask.Dispose();
                _bracerCotask = null;
            }

            if (_bracerLibrary != null)
            {
                _bracerLibrary.Dispose();
                _bracerLibrary = null;
            }
        }
        /// <summary>
        /// Start bracer task on node.
        /// </summary>
        /// <param name="node">Node to start task on.</param>
        protected virtual void StartBracerTask(NodeHandle node)
        {
            var network = GetNativeNetwork();

            if (network == null)
            {
                return;
            }

            if (_bracerCotask != null)
            {
                Debug.LogWarningFormat("Bracer task already running on node {0}", BracerNode.value);
                return;
            }

            if (_bracerLibrary == null)
            {
                Debug.LogError("Bracer library is null");
                return;
            }

            if (network.nodeGetStatus(node) != NodeStatus.Idle)
            {
                Debug.LogError("Wrong node status");
                return;
            }

            using (var cotaskConstructor = _bracerLibrary.getCotaskConstructor()) {
                if (cotaskConstructor == null)
                {
                    Debug.LogError("Failed to get bracer cotask constructor");
                    return;
                }

                _bracerCotask = cotaskConstructor.startTask(network, node);
                if (_bracerCotask == null)
                {
                    StopBracerTask();
                    Debug.LogWarning("Failed to start bracer task on node " + node.value);
                    return;
                }

                BracerNode = node;
                BracerStateChanged.Invoke(BracerState.Connected);
            }
        }