Beispiel #1
0
        /// <summary>
        /// Follow the user sent in. Anytime a message is tweeted, this user will be notified
        /// and the ReceiveFeed method kicked of.
        /// </summary>
        /// <param name="theuser"></param>
        public override void AddFollowing(BaseUser theuser)
        {
            HashSet<BaseUser>.Enumerator hbe = Following.GetEnumerator();
            while (hbe.MoveNext())
            {
                if (hbe.Current.UserName.Equals(theuser.UserName))
                    return;
            }

            theuser.AddObserver(new NotifyObserver(this.ReceiveFeed));
            Following.Add(theuser);
        }
Beispiel #2
0
        /// <summary>
        /// Adds the user if not exists, otherwise just add the follower
        /// </summary>
        /// <param name="username"></param>
        /// <param name="followername"></param>
        public void AddUser(string username, string followername)
        {
            follower = FindUser(followername);
            if (follower == null)
            {
                follower = UserFactory.CreateUser(followername);
                AllUsers.Add(follower.UserName, follower);
            }

            user = FindUser(username);
            if (user != null)
            {
                follower.AddFollowing(user);
                return;
            }
            else
            {
                // user does not already exists, add the user and the follower
                user = UserFactory.CreateUser(username);
                follower.AddFollowing(user);
                AllUsers.Add(user.UserName, user);
            }
        }
Beispiel #3
0
        /// <summary>
        /// textline should be of format: x> msg with msg not being longer than 140 characters in length
        /// textline should already be validated by this point
        /// </summary>
        /// <param name="textline"></param>
        private void ParseTweetLine(string textline)
        {
            if (textline.Equals(String.Empty))
                return;

            // get author name
            string[] parts = textline.Split('>');

            if (parts.Count() <= 0)
                return;

            user = FindUser(parts[0].ToLowerInvariant());
            if (user == null)
                return;

            user.Tweet(MessageFactory.CreateMessage(parts[1], parts[0]));
        }
Beispiel #4
0
 public abstract void AddFollowing(BaseUser theuser);