コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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);
            }
        }