/// <summary> /// Adds a new friend to the friend list. /// If they are already a friend, nothing happens. /// </summary> /// <param name="Friend">The friend to add to the friend list.</param> public Messenger AddFriend(Friend Friend) { lock (this) { if (this.fFriends.ContainsKey(Friend.GetUser().GetID())) // Check if they are already a friend. { return(this); // They are, abort! } this.fFriends.Add(Friend.GetUser().GetID(), Friend); // Nope, not a friend. Add them. } AddUpdate(new FriendUpdate(FriendUpdateActions.Add, Friend)); // Add the friend to the update data. return(this); }
/// <summary> /// Remove a Friend from the friend list. /// </summary> /// <param name="Friend">The Friend to remove.</param> public Messenger RemoveFriend(Friend Friend) { AddUpdate(new FriendUpdate(FriendUpdateActions.Remove, Friend)); lock (this) { if (!this.fFriends.ContainsKey(Friend.GetUser().GetID())) // Does the Friend exist in the friend list? { this.fFriends.Remove(Friend.GetUser().GetID()); // Yes, remove it. } } SendUpdates(); // Force an early update. return(this); }