/// <summary>
 ///   Get a Friend from an IBefriendable.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to return the Friend instance for.</param>
 /// <returns>The instance of Friend for befriendable. If befriendable is not a friend then null is returned.</returns>
 public Friend GetFriend(IBefriendable befriendable)
 {
     if (!_friends.ContainsKey(befriendable.GetID()))
     {
         return(null);
     }
     return(_friends[befriendable.GetID()]);
 }
Exemple #2
0
 public MessengerCategory AddFriend(IBefriendable friend)
 {
     if (friend is Habbo)
         _habboFriends.Add(friend.Id, friend as Habbo);
     else
         _otherFriends.Add(friend);
     return this;
 }
        public MessengerObject SendFriendRequest(IBefriendable befriendable)
        {
            MessengerObject messenger = befriendable.GetMessenger();

            if (messenger != null)
            {
                messenger.ReceiveFriendRequest(Owner);
            }
            return(this);
        }
Exemple #4
0
 public MessengerCategory AddFriend(IBefriendable friend)
 {
     if (friend is Habbo)
     {
         _habboFriends.Add(friend.Id, friend as Habbo);
     }
     else
     {
         _otherFriends.Add(friend);
     }
     return(this);
 }
        /// <summary>
        ///   Add an IBefriendable as a friend only if the IBefriendable is not already a friend.
        /// </summary>
        /// <param name = "befriendable">The IBefriendable to add.</param>
        /// <returns>The instance of MessengerObject this was called on. This allows for chaining.</returns>
        public MessengerObject AddNewFriend(IBefriendable befriendable)
        {
            if (_friends.ContainsKey(befriendable.GetID()))
            {
                return(this);
            }

            Friend friend = new Friend(befriendable);

            _friends.Add(befriendable.GetID(), friend);

            return(this);
        }
        /// <summary>
        /// </summary>
        /// <param name = "befriendable"></param>
        /// <returns></returns>
        public MessengerObject RemoveFriendRequest(IBefriendable befriendable)
        {
            if (!_friendRequests.ContainsKey(befriendable.GetID()))
            {
                return(this);
            }

            _friendRequests.Remove(befriendable.GetID());

            if (OnFriendRequestRemoved != null)
            {
                OnFriendRequestRemoved.Invoke(this, new MessengerFriendRequestEventArgs(befriendable, Owner));
            }

            return(this);
        }
        public MessengerObject AddFriendToCategory(IBefriendable befriendable, Category category)
        {
            if (!_friends.ContainsKey(befriendable.GetID()))
            {
                return(this);
            }

            Friend friend = _friends[befriendable.GetID()];

            if (!friend.Categories.ContainsKey(category.ID))
            {
                friend.Categories.Add(category.ID, category);
            }

            if (!category.Friends.ContainsKey(befriendable.GetID()))
            {
                category.Friends.Add(befriendable.GetID(), befriendable);
            }
            return(this);
        }
        private static void ProcessMessengerSearch(Habbo sender, IncomingMessage message)
        {
            string searchString = message.PopPrefixedString();

            List <IHI.Database.Habbo> matching;

            // Using IHIDB.Habbo rather than IHIDB.Friend because this will be passed to the HabboDistributor
            using (ISession db = CoreManager.ServerCore.GetDatabaseSession())
            {
                matching = db.CreateCriteria <IHI.Database.Habbo>().
                           Add(new LikeExpression("username", searchString + "%")).
                           SetMaxResults(20).     // TODO: External config
                           List <IHI.Database.Habbo>() as List <IHI.Database.Habbo>;
            }

            List <IBefriendable> friends   = new List <IBefriendable>();
            List <IBefriendable> strangers = new List <IBefriendable>();

            MessengerObject  messenger        = sender.GetMessenger();
            HabboDistributor habboDistributor = CoreManager.ServerCore.GetHabboDistributor();

            foreach (IHI.Database.Habbo match in matching)
            {
                IBefriendable habbo = habboDistributor.GetHabbo(match);
                if (messenger.IsFriend(habbo))
                {
                    friends.Add(habbo);
                }
                else
                {
                    strangers.Add(habbo);
                }
            }

            new MMessengerSearchResults(friends, strangers).Send(sender);
        }
 public MessengerObject RemoveFriendFromCategory(IBefriendable befriendable, Category category)
 {
     RemoveFriendFromCategory(befriendable.GetID(), category);
     return(this);
 }
 public MessengerObject RemoveFriend(IBefriendable befriendable)
 {
     RemoveFriend(befriendable.GetID());
     return(this);
 }
 public static MessengerObject GetMessenger(this IBefriendable friend)
 {
     return(friend.GetInstanceVariable("Messenger.Instance") as MessengerObject);
 }
 /// <summary>
 ///   Get a Friend from an IBefriendable.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to return the Friend instance for.</param>
 /// <returns>The instance of Friend for befriendable. If befriendable is not a friend then null is returned.</returns>
 public Friend GetFriend(IBefriendable befriendable)
 {
     if (!_friends.ContainsKey(befriendable.GetID()))
         return null;
     return _friends[befriendable.GetID()];
 }
Exemple #13
0
 public Friend(IBefriendable befriendableObject)
 {
     Befriendable = befriendableObject;
     Categories   = new Dictionary <int, Category>();
 }
Exemple #14
0
 public Category RemoveFriend(IBefriendable befriendable)
 {
     Owner.RemoveFriendFromCategory(befriendable, this);
     return this;
 }
Exemple #15
0
 public Category AddFriend(IBefriendable befriendable)
 {
     Owner.AddFriendToCategory(befriendable, this);
     return this;
 }
 public MessengerFriendRequestEventArgs(IBefriendable from, IBefriendable to)
 {
     _from = from;
     _to   = to;
 }
 public MMessengerSearchResults AddStranger(IBefriendable stranger)
 {
     _strangers.Add(stranger);
     return(this);
 }
 public MessengerObject RemoveFriendFromCategory(IBefriendable befriendable, Category category)
 {
     RemoveFriendFromCategory(befriendable.GetID(), category);
     return this;
 }
        /// <summary>
        /// </summary>
        /// <param name = "befriendable"></param>
        /// <returns></returns>
        public MessengerObject RemoveFriendRequest(IBefriendable befriendable)
        {
            if (!_friendRequests.ContainsKey(befriendable.GetID()))
                return this;

            _friendRequests.Remove(befriendable.GetID());

            if (OnFriendRequestRemoved != null)
                OnFriendRequestRemoved.Invoke(this, new MessengerFriendRequestEventArgs(befriendable, Owner));

            return this;
        }
 public MessengerObject RemoveFriend(IBefriendable befriendable)
 {
     RemoveFriend(befriendable.GetID());
     return this;
 }
 /// <summary>
 ///   Check if there is an outstanding request from an IBefriendable.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to check for requests from.</param>
 /// <returns>True if befriendable is already a friend, false otherwise.</returns>
 public bool IsRequestedBy(IBefriendable befriendable)
 {
     return _friendRequests.ContainsKey(befriendable.GetID());
 }
 /// <summary>
 ///   Check if an IBefriendable is already an friend.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to check for.</param>
 /// <returns>True if befriendable is already a friend, false otherwise.</returns>
 public bool IsFriend(IBefriendable befriendable)
 {
     return _friends.ContainsKey(befriendable.GetID());
 }
 /// <summary>
 ///   Check if there is an outstanding request from an IBefriendable.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to check for requests from.</param>
 /// <returns>True if befriendable is already a friend, false otherwise.</returns>
 public bool IsRequestedBy(IBefriendable befriendable)
 {
     return(_friendRequests.ContainsKey(befriendable.GetID()));
 }
Exemple #24
0
 public Category AddFriend(IBefriendable befriendable)
 {
     Owner.AddFriendToCategory(befriendable, this);
     return(this);
 }
Exemple #25
0
 public Friend(IBefriendable befriendableObject)
 {
     Befriendable = befriendableObject;
     Categories = new Dictionary<int, Category>();
 }
Exemple #26
0
 public Category RemoveFriend(IBefriendable befriendable)
 {
     Owner.RemoveFriendFromCategory(befriendable, this);
     return(this);
 }
 /// <summary>
 ///   Check if an IBefriendable is already an friend.
 /// </summary>
 /// <param name = "befriendable">The IBefriendable to check for.</param>
 /// <returns>True if befriendable is already a friend, false otherwise.</returns>
 public bool IsFriend(IBefriendable befriendable)
 {
     return(_friends.ContainsKey(befriendable.GetID()));
 }
        public MessengerObject AddFriendToCategory(IBefriendable befriendable, Category category)
        {
            if (!_friends.ContainsKey(befriendable.GetID()))
                return this;

            Friend friend = _friends[befriendable.GetID()];

            if (!friend.Categories.ContainsKey(category.ID))
                friend.Categories.Add(category.ID, category);

            if (!category.Friends.ContainsKey(befriendable.GetID()))
                category.Friends.Add(befriendable.GetID(), befriendable);
            return this;
        }
 public MessengerObject SendFriendRequest(IBefriendable befriendable)
 {
     MessengerObject messenger = befriendable.GetMessenger();
     if (messenger != null)
         messenger.ReceiveFriendRequest(Owner);
     return this;
 }
        /// <summary>
        ///   Add an IBefriendable as a friend only if the IBefriendable is not already a friend.
        /// </summary>
        /// <param name = "befriendable">The IBefriendable to add.</param>
        /// <returns>The instance of MessengerObject this was called on. This allows for chaining.</returns>
        public MessengerObject AddNewFriend(IBefriendable befriendable)
        {
            if (_friends.ContainsKey(befriendable.GetID()))
                return this;

            Friend friend = new Friend(befriendable);
            _friends.Add(befriendable.GetID(), friend);

            return this;
        }
 public MessengerFriendRequestEventArgs(IBefriendable from, IBefriendable to)
 {
     _from = from;
     _to = to;
 }
 public MMessengerSearchResults AddFriend(IBefriendable friend)
 {
     _friends.Add(friend);
     return(this);
 }