Ejemplo n.º 1
0
        public void OnNewFriendship(int friendID)
        {
            GameClient friend = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);

            MessengerBuddy newFriend;

            if (friend == null || friend.GetHabbo() == null)
            {
                DataRow dRow;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT id,username,motto,look,last_online,hide_inroom,hide_online FROM users WHERE `id` = @friendid LIMIT 1");
                    dbClient.AddParameter("friendid", friendID);
                    dRow = dbClient.getRow();
                }

                newFriend = new MessengerBuddy(friendID, Convert.ToString(dRow["username"]), Convert.ToString(dRow["look"]), Convert.ToString(dRow["motto"]), Convert.ToInt32(dRow["last_online"]),
                                               PlusEnvironment.EnumToBool(dRow["hide_online"].ToString()), PlusEnvironment.EnumToBool(dRow["hide_inroom"].ToString()), false);
            }
            else
            {
                Habbo user = friend.GetHabbo();


                newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto, 0, user.AppearOffline, user.AllowPublicRoomStatus, false);
                newFriend.UpdateUser(friend);
            }

            if (!_friends.ContainsKey(friendID))
            {
                _friends.Add(friendID, newFriend);
            }

            GetClient().SendMessage(SerializeUpdate(newFriend));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when [new friendship].
        /// </summary>
        /// <param name="friendId">The friend identifier.</param>
        internal void OnNewFriendship(uint friendId)
        {
            var            clientByUserId = Plus.GetGame().GetClientManager().GetClientByUserId(friendId);
            MessengerBuddy messengerBuddy;

            if (clientByUserId == null || clientByUserId.GetHabbo() == null)
            {
                DataRow row;
                using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.SetQuery(
                        string.Format(
                            "SELECT id,username,motto,look,last_online,hide_inroom,hide_online FROM users WHERE id = {0}",
                            friendId));
                    row = queryReactor.GetRow();
                }
                messengerBuddy = new MessengerBuddy(friendId, (string)row["Username"], (string)row["look"],
                                                    (string)row["motto"], (int)row["last_online"], Plus.EnumToBool(row["hide_online"].ToString()),
                                                    Plus.EnumToBool(row["hide_inroom"].ToString()));
            }
            else
            {
                var habbo = clientByUserId.GetHabbo();
                messengerBuddy = new MessengerBuddy(friendId, habbo.UserName, habbo.Look, habbo.Motto, 0,
                                                    habbo.AppearOffline, habbo.HideInRoom);
                messengerBuddy.UpdateUser();
            }
            if (!Friends.ContainsKey(friendId))
            {
                Friends.Add(friendId, messengerBuddy);
            }
            GetClient().SendMessage(SerializeUpdate(messengerBuddy));
        }
Ejemplo n.º 3
0
        public FriendListUpdateComposer(GameClient Session, MessengerBuddy Buddy)
            : base(ServerPacketHeader.FriendListUpdateMessageComposer)
        {
            base.WriteInteger(0);//Category Count
            base.WriteInteger(1);//Updates Count
            base.WriteInteger(0);//Update

            Relationship Relationship = Session.GetHabbo().Relationships.FirstOrDefault(x => x.Value.UserId == Convert.ToInt32(Buddy.UserId)).Value;
            int y = Relationship == null ? 0 : Relationship.Type;

            base.WriteInteger(Buddy.UserId);
           base.WriteString(Buddy.mUsername);
            base.WriteInteger(1);
            if (!Buddy.mAppearOffline || Session.GetHabbo().GetPermissions().HasRight("mod_tool"))
                base.WriteBoolean(Buddy.IsOnline);
            else
                base.WriteBoolean(false);

            if (!Buddy.mHideInroom || Session.GetHabbo().GetPermissions().HasRight("mod_tool"))
                base.WriteBoolean(Buddy.InRoom);
            else
                base.WriteBoolean(false);

           base.WriteString("");//Habbo.IsOnline ? Habbo.Look : "");
            base.WriteInteger(0); // categoryid
           base.WriteString(Buddy.mMotto);
           base.WriteString(string.Empty); // Facebook username
           base.WriteString(string.Empty);
            base.WriteBoolean(true); // Allows offline messaging
            base.WriteBoolean(false); // ?
            base.WriteBoolean(false); // Uses phone
            base.WriteShort(y);
        }
Ejemplo n.º 4
0
        public ServerPacket SerializeUpdate(MessengerBuddy friend)
        {
            var packet = new ServerPacket(ServerPacketHeader.FriendListUpdateMessageComposer);

            packet.WriteInteger(0); // category count
            packet.WriteInteger(1); // number of updates
            packet.WriteInteger(0); // don't know
            friend.Serialize(packet, GetClient());
            return(packet);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Serializes the update.
        /// </summary>
        /// <param name="friend">The friend.</param>
        /// <returns>ServerMessage.</returns>
        internal ServerMessage SerializeUpdate(MessengerBuddy friend)
        {
            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FriendUpdateMessageComposer"));

            serverMessage.AppendInteger(0);
            serverMessage.AppendInteger(1);
            serverMessage.AppendInteger(0);
            friend.Serialize(serverMessage, GetClient());
            serverMessage.AppendBool(false);
            return(serverMessage);
        }
Ejemplo n.º 6
0
 public bool TryGetFriend(int UserId, out MessengerBuddy Buddy)
 {
     return(this._friends.TryGetValue(UserId, out Buddy));
 }
Ejemplo n.º 7
0
 public bool TryGetFriend(int userId, out MessengerBuddy buddy) => _friends.TryGetValue(userId, out buddy);
Ejemplo n.º 8
0
 public MessageComposer SerializeUpdate(MessengerBuddy friend)
 {
     return(new FriendListUpdateComposer(GetClient().GetHabbo(), friend));
 }
Ejemplo n.º 9
0
 public bool TryGetFriend(int UserId, out MessengerBuddy Buddy)
 {
     return this._friends.TryGetValue(UserId, out Buddy);
 }
Ejemplo n.º 10
0
        public ServerPacket SerializeUpdate(MessengerBuddy friend)
        {
            ServerPacket Packet = new ServerPacket(ServerPacketHeader.FriendListUpdateMessageComposer);
            Packet.WriteInteger(0); // category count
            Packet.WriteInteger(1); // number of updates
            Packet.WriteInteger(0); // don't know

            friend.Serialize(Packet, GetClient());
            return Packet;
        }
Ejemplo n.º 11
0
        public void OnNewFriendship(int friendID)
        {
            GameClient friend = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID);

            MessengerBuddy newFriend;
            if (friend == null || friend.GetHabbo() == null)
            {
                DataRow dRow;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT id,username,motto,look,last_online,hide_inroom,hide_online FROM users WHERE `id` = @friendid LIMIT 1");
                    dbClient.AddParameter("friendid", friendID);
                    dRow = dbClient.getRow();
                }

                newFriend = new MessengerBuddy(friendID, Convert.ToString(dRow["username"]), Convert.ToString(dRow["look"]), Convert.ToString(dRow["motto"]), Convert.ToInt32(dRow["last_online"]),
                    PlusEnvironment.EnumToBool(dRow["hide_online"].ToString()), PlusEnvironment.EnumToBool(dRow["hide_inroom"].ToString()));
            }
            else
            {
                Habbo user = friend.GetHabbo();

                newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto, 0, user.AppearOffline, user.AllowPublicRoomStatus);
                newFriend.UpdateUser(friend);
            }

            if (!_friends.ContainsKey(friendID))
                _friends.Add(friendID, newFriend);

            GetClient().SendMessage(SerializeUpdate(newFriend));
        }