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); } }