public string this [UserStruct user]
        {
            get
            {
                return(UsersCache[user]);
            }

            set
            {
                var past = UsersCache[user];

                UsersCache[user] = value;

                if (past.IsNotNull())
                {
                    OnConnectionRemove?.Invoke(this, past);
                    OnConnectionRemoveOtherData?.Invoke(user, past);
                }

                if (value.IsNotNull())
                {
                    OnConnectionAdd?.Invoke(this, value);
                    OnConnectionAddOtherData?.Invoke(user, value);
                }
            }
        }
        public void AddUser(UserStruct user, string connection)
        {
            lock (UsersCache)
            {
                UsersCache.Add(user, connection);

                UserIdCounter++;
                UserIdCache.Add(user, UserIdCounter);
            }

            if (connection.IsNotNull())
            {
                OnConnectionAdd?.Invoke(this, connection);
                OnConnectionAddOtherData?.Invoke(user, connection);
            }
        }
Exemple #3
0
        public NC ConnectTo(N to, C context, NodeConnectionDirection direction = NodeConnectionDirection.Bidirectional,
                            float weight = 0)
        {
            if (to == null)
            {
                Debug.LogError("[LinkedNode:ConnectTo()] -> Target node cannot be null.");
                return(null);
            }

            if (to == this)
            {
                Debug.LogError("[LinkedNode:ConnectTo()] -> You cant connect to yourself.");
                return(null);
            }

            NC newConnection = Owner.CreateConnection(this as N, to, context, direction, weight);

            Connections.Add(newConnection);
            to.Connections.Add(newConnection);
            OnConnectionAdd?.Invoke(newConnection);
            return(newConnection);
        }