Exemplo n.º 1
0
        /// <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.GetHabbo().GetID()))    // Check if they are already a friend.
                    return this;                                            // They are, abort!
                this.fFriends.Add(Friend.GetHabbo().GetID(), Friend);        // Nope, not a friend. Add them.
            }

            AddUpdate(new FriendUpdate(FriendUpdateActions.Add, Friend));   // Add the friend to the update data.

            return this;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Send all updates in the update buffer to the client.
        /// The buffer is cleared afterwards.
        /// </summary>
        internal Messenger SendUpdates()
        {
            Friend[] Friends = new Friend[this.fFriends.Count];

            this.fFriends.Values.CopyTo(Friends, 0);

            // this.fUser.GetPacketSender().Send_FriendListUpdate(this.fCategories.ToArray(), Friends, this.fUpdateList.ToArray()); // TODO: Move to a plugin!

            this.fUpdateList.Clear();

            return this;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Send the initial (at logon) list of friends and categories.
        /// </summary>
        internal Messenger SendInitialList()
        {
            Friend[] Friends = new Friend[this.fFriends.Count];

            this.fFriends.Values.CopyTo(Friends, 0);

            // this.fUser.GetPacketSender().Send_MessengerInit(200, 200, 600, this.fCategories.ToArray(), Friends, 200); // TODO: Move to a plugin!

            return this;
        }
Exemplo n.º 4
0
        /// <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.GetHabbo().GetID()))   // Does the Friend exist in the friend list?
                    this.fFriends.Remove(Friend.GetHabbo().GetID());         // Yes, remove it.
            }

            SendUpdates();  // Force an early update.

            return this;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Send the initial messenger configuration and contents.
        /// </summary>
        /// <param name="A">Unsure</param>
        /// <param name="B">Unsure</param>
        /// <param name="C">Unsure</param>
        public void Send_MessengerInit(int A, int B, int C, Category[] Categories, Friend[] Friends, uint MaxFriends)
        {
            OutgoingMessage Message = new OutgoingMessage(12);
            Message.AppendInt32(A);     // Find out
            Message.AppendInt32(B);     // Find out
            Message.AppendInt32(C);     // Find out

            Message.AppendInt32(Categories.Length);

            for (int i = 0; i < Categories.Length; i++)
            {
                Message.AppendUInt32(Categories[i].GetID());
                Message.AppendString(Categories[i].GetName());
            }

            Message.AppendInt32(Friends.Length);

            for (int i = 0; i < Friends.Length; i++)
            {
                Message.AppendObject(Friends[i]);
            }

            Message.AppendUInt32(MaxFriends);
            Message.AppendBoolean(false);       // TODO: Find out
        }
Exemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Categories">An array of all categories to show to the user.</param>
        /// <param name="Friends">An array of all friends to show to the user.</param>
        /// <param name="FriendUpdates">An array of all changes to the friends list to send to the user.</param>
        public void Send_FriendListUpdate(Category[] Categories, Friend[] Friends, FriendUpdate[] FriendUpdates)
        {
            OutgoingMessage Message = new OutgoingMessage(13);
            Message.AppendInt32(Categories.Length);

            for (int i = 0; i < Categories.Length; i++)
            {
                Message.AppendUInt32(Categories[i].GetID());
                Message.AppendString(Categories[i].GetName());
            }

            Message.AppendInt32(Friends.Length + FriendUpdates.Length);

            for (int i = 0; i < FriendUpdates.Length; i++)
            {
                Message.AppendObject(FriendUpdates[i]);
            }

            for (int i = 0; i < Friends.Length; i++)
            {
                Message.AppendObject(Friends[i]);
            }
        }