Ejemplo n.º 1
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            request.GetBool(); // TODO Unused

            string idAsString = request.GetString();

            int userId;

            int.TryParse(idAsString, out userId);

            if (userId == 0)
            {
                return;
            }

            string message = request.GetString();

            Habbo guide = GuideManager.GetRandomGuide();

            if (guide == null)
            {
                router.GetComposer <OnGuideSessionErrorComposer>().Compose(session);
                return;
            }

            router.GetComposer <OnGuideSessionAttachedMessageComposer>().Compose(session, false, userId, message, 30);
            router.GetComposer <OnGuideSessionAttachedMessageComposer>().Compose(guide, true, userId, message, 15);

            guide.GuideOtherUser   = session;
            session.GuideOtherUser = guide;
        }
Ejemplo n.º 2
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            string newName = message.GetString();

            List <string> alternatives;

            NameChangedUpdatesMessageComposer.Status status = Validate(newName, session.Info.Name, out alternatives);

            if (status == NameChangedUpdatesMessageComposer.Status.OK)
            {
                session.Info.Name = newName;

                router.GetComposer <UpdateUsernameMessageComposer>().Compose(session, newName);
                // TODO Refactor

                UserRepository.Save(session.Info);

                if (session.Room != null)
                {
                    session.Room.EachUser(
                        (roomSession) =>
                    {
                        router.GetComposer <UserUpdateNameInRoomMessageComposer>()
                        .Compose(roomSession, session);
                    }
                        );
                }

                // TODO Update room owner

                // TODO Notify messenger
            }
        }
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            if (session.Room == null ||
                !session.Room.Data.HasOwnerRights(session.Info))
            {
                return;
            }

            int itemId = message.GetInteger();

            SongItem item = session.Info.Inventory.GetFloorItem(itemId) as SongItem;

            if (item == null)
            {
                return;
            }

            SongMachineComponent songMachine = session.Room.Data.SongMachine;

            if (songMachine.TryAdd(item))
            {
                session.Info.Inventory.FloorItems.Remove(item);
                router.GetComposer <RemoveInventoryObjectMessageComposer>().Compose(session, item.Id);

                ItemRepository.Save(item);
            }

            router.GetComposer <JukeboxPlaylistMessageComposer>().Compose(session, songMachine);
        }
Ejemplo n.º 4
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            int groupId    = request.GetInteger();
            int threadId   = request.GetInteger();
            int stateToSet = request.GetInteger();

            Group theGroup = GroupRepository.Find(groupId);

            if (theGroup != null)
            {
                GroupForumThread thread = theGroup.Forum.GetThread(threadId);

                if (thread != null && (thread.Creator == session.Info || theGroup.Admins.Contains(session.Info)))
                {
                    thread.Hidden   = stateToSet == 20;
                    thread.HiddenBy = session.Info;

                    GroupRepository.Save(theGroup);

                    router.GetComposer <SuperNotificationMessageComposer>()
                    .Compose(session, string.Empty, string.Empty, string.Empty, string.Empty,
                             stateToSet == 20 ? "forums.thread.hidden" : "forums.thread.restored", 0);

                    router.GetComposer <GroupForumThreadUpdateMessageComposer>()
                    .Compose(session, groupId, thread, thread.Pinned, thread.Locked);
                }
            }
        }
Ejemplo n.º 5
0
        // TODO Refactor
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            int userId = request.GetInteger();

            Relationship relationship = session.Info.Relationships.FindByUser(userId);

            if (relationship == null)
            {
                router.GetComposer <FollowFriendErrorMessageComposer>().Compose(session, 0);
            }
            else
            {
                var friendSession = ClientManager.GetByUserId(userId);

                if (friendSession == null || friendSession.Room == null)
                {
                    router.GetComposer <FollowFriendErrorMessageComposer>().Compose(session, 2);
                }
                else
                {
                    router.GetComposer <RoomForwardMessageComposer>().Compose(session, friendSession.Room.Data.Id);
                }
            }
        }
Ejemplo n.º 6
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            if (session.Room == null)
            {
                return;
            }

            int itemId = message.GetInteger();

            SongMachineComponent songMachine = session.Room.Data.SongMachine;

            SongItem item = songMachine.Find(itemId);

            if (item == null)
            {
                return;
            }

            songMachine.Remove(item);
            session.Info.Inventory.FloorItems.Add(item);
            ItemRepository.Save(item);

            SongItem[] items = session.Info.Inventory.FloorItems.OfType <SongItem>().ToArray();

            router.GetComposer <UpdateInventoryMessageComposer>().Compose(session);
            router.GetComposer <SongsLibraryMessageComposer>().Compose(session, items);
            router.GetComposer <JukeboxPlaylistMessageComposer>().Compose(session, songMachine);
        }
Ejemplo n.º 7
0
 public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                    Yupi.Protocol.IRouter router)
 {
     router.GetComposer <SubscriptionStatusMessageComposer>().Compose(session, session.Info.Subscription);
     // TODO Implement Ambassador
     router.GetComposer <UserClubRightsMessageComposer>().Compose(session, session.Info.Subscription.GetLevel(), session.Info.Rank, false);
 }
Ejemplo n.º 8
0
 public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                    Yupi.Protocol.IRouter router)
 {
     router.GetComposer <NavigatorMetaDataComposer>().Compose(session);
     router.GetComposer <NavigatorLiftedRoomsComposer>().Compose(session);
     router.GetComposer <NavigatorCategoriesComposer>().Compose(session, NavigatorRepository.All().ToList());
     router.GetComposer <NavigatorSavedSearchesComposer>().Compose(session, session.Info.NavigatorLog);
     router.GetComposer <NewNavigatorSizeMessageComposer>().Compose(session, session.Info.Preferences);
 }
Ejemplo n.º 9
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            string message = request.GetString();

            router.GetComposer <OnGuideSessionMsgMessageComposer>()
            .Compose(session.GuideOtherUser, message, session.Info.Id);
            router.GetComposer <OnGuideSessionMsgMessageComposer>().Compose(session, message, session.Info.Id);
        }
Ejemplo n.º 10
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            request.GetUInt32(); // TODO Unused!
            session.Info.FavouriteGroup = null;

            UserRepository.Save(session.Info);

            router.GetComposer <FavouriteGroupMessageComposer>().Compose(session, session.Info.Id);
            router.GetComposer <ChangeFavouriteGroupMessageComposer>().Compose(session, null, 0);
        }
Ejemplo n.º 11
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            Habbo requester = session.GuideOtherUser;

            // TODO Test & Fixme !!!

            router.GetComposer <OnGuideSessionDetachedMessageComposer>().Compose(requester, 2);
            router.GetComposer <OnGuideSessionDetachedMessageComposer>().Compose(session, 0);

            requester.GuideOtherUser = null;
            session.GuideOtherUser   = null;
        }
Ejemplo n.º 12
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            List <Room> rooms = RoomManager.GetActive().ToList();

            router.GetComposer <FindMoreFriendsSuccessMessageComposer>().Compose(session, rooms.Any());

            Room room = rooms.Random();

            if (room != null)
            {
                router.GetComposer <RoomForwardMessageComposer>().Compose(session, room.Data.Id);
            }
        }
Ejemplo n.º 13
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            string gender = message.GetString();
            string look   = message.GetString();

            // TODO Validate gender & look
            session.Info.Look   = look;
            session.Info.Gender = gender;
            UserRepository.Save(session.Info);

            AchievementManager.ProgressUserAchievement(session, ProfileAchievement.AvatarLooks);

            if (session.Room == null)
            {
                return;
            }

            router.GetComposer <UpdateAvatarAspectMessageComposer>().Compose(session, session.Info);

            session.Room.EachUser(
                (roomSession) =>
            {
                roomSession.Router.GetComposer <UpdateUserDataMessageComposer>()
                .Compose(roomSession, session.Info, session.RoomEntity.Id);
            }
                );

            MessengerController.UpdateUser(session.Info);
        }
Ejemplo n.º 14
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            string whatever = message.GetString(); // TODO What does the string contain?

            router.GetComposer <CitizenshipStatusMessageComposer>().Compose(session, whatever);
        }
Ejemplo n.º 15
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            SongItem[] items = session.Info.Inventory.FloorItems.OfType <SongItem>().ToArray();

            router.GetComposer <SongsLibraryMessageComposer>().Compose(session, items);
        }
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            string code = message.GetString();

            router.GetComposer <HotelViewHallOfFameMessageComposer>().Compose(session, code);
        }
Ejemplo n.º 17
0
        // TODO Refactor
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            int    groupId     = request.GetInteger();
            string name        = request.GetString();
            string description = request.GetString();

            Group theGroup = GroupRepository.Find(groupId);

            if (theGroup?.Creator != session.Info)
            {
                return;
            }

            theGroup.Name        = name;
            theGroup.Description = description;

            GroupRepository.Save(theGroup);

            if (session.Room != null)
            {
                session.Room.EachUser(
                    (entitySession) =>
                {
                    entitySession.Router.GetComposer <GroupDataMessageComposer>()
                    .Compose(entitySession, theGroup, session.Info);
                });
            }
            else
            {
                router.GetComposer <GroupDataMessageComposer>().Compose(session, theGroup, session.Info);
            }
        }
Ejemplo n.º 18
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            Room room = session.Room;

            int userId = message.GetInteger();

            UserEntity roomUserByHabbo = room?.GetEntity(userId) as UserEntity;

            if (roomUserByHabbo == null)
            {
                return;
            }

            router.GetComposer <UserTagsMessageComposer>()
            .Compose(session, roomUserByHabbo.UserInfo);

            // TODO Move to proper place!

            /*
             * if (session.Info.Tags.Count >= 5) {
             *  Yupi.GetGame ()
             *      .GetAchievementManager ()
             *      .ProgressUserAchievement (roomUserByHabbo.GetClient (), "ACH_UserTags", 5);
             *
             * }*/
        }
Ejemplo n.º 19
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            string friendName = request.GetString();

            UserInfo friend = UserRepository.Find(x => x.Name == friendName);

            if (friend != null)
            {
                if (friend.HasFriendRequestsDisabled)
                {
                    router.GetComposer <NotAcceptingRequestsMessageComposer>().Compose(session);
                }
                else
                {
                    IRepository <FriendRequest> requests = DependencyFactory.Resolve <IRepository <FriendRequest> > ();

                    if (!requests.Exists(x => x.To == friend && x.From == session.Info))
                    {
                        var friendRequest = new FriendRequest(session.Info, friend);

                        requests.Save(friendRequest);

                        var friendSession = ClientManager.GetByInfo(friend);

                        if (friendSession != null)
                        {
                            friendSession.Router.GetComposer <ConsoleSendFriendRequestMessageComposer>()
                            .Compose(friendSession, friendRequest);
                        }
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            List <RoomData> rooms = session.Info.UsersRooms.Where(x => x.Group == null).ToList();

            router.GetComposer <GroupPurchasePageMessageComposer>().Compose(session, rooms);
        }
Ejemplo n.º 21
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            int groupId    = request.GetInteger();
            int threadId   = request.GetInteger();
            int startIndex = request.GetInteger();

            request.GetInteger(); // TODO Unused

            Group theGroup = GroupRepository.Find(groupId);

            if (theGroup == null)
            {
                return;
            }

            GroupForumThread thread = theGroup.Forum.GetThread(threadId);

            if (thread == null)
            {
                return;
            }

            // TODO Magic constant
            List <GroupForumPost> posts = thread.Posts.Skip(startIndex).Take(20).ToList();

            router.GetComposer <GroupForumReadThreadMessageComposer>()
            .Compose(session, groupId, threadId, startIndex, posts);
        }
Ejemplo n.º 22
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            int groupId      = request.GetInteger();
            int whoCanRead   = request.GetInteger();
            int whoCanPost   = request.GetInteger();
            int whoCanThread = request.GetInteger();
            int whoCanMod    = request.GetInteger();

            Group group = GroupRepository.Find(groupId);

            if (group?.Creator != session.Info)
            {
                return;
            }

            // TODO Check rights?!
            group.Forum.WhoCanRead   = whoCanRead;
            group.Forum.WhoCanPost   = whoCanPost;
            group.Forum.WhoCanThread = whoCanThread;
            group.Forum.WhoCanMod    = whoCanMod;

            GroupRepository.Save(group);
            router.GetComposer <GroupForumDataMessageComposer>().Compose(session, group, session.Info);
        }
Ejemplo n.º 23
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            int windowId = message.GetInteger();

            router.GetComposer <CatalogueClubPageMessageComposer>().Compose(session, windowId);
        }
Ejemplo n.º 24
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            var openTickets = session.Info.SupportTickets.Where(x => x.Status != TicketStatus.Closed);

            router.GetComposer <OpenHelpToolMessageComposer>().Compose(session, openTickets.ToList());
        }
Ejemplo n.º 25
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            string name = request.GetString();

            // TODO Refactor
            switch (name)
            {
            case "predefined_noob_lobby":
            {
                /*
                 * int roomId = Convert.ToUInt32(Yupi.GetDbConfig().DbData["noob.lobby.roomid"]);
                 * router.GetComposer<RoomForwardMessageComposer> ().Compose (session, roomId);*/
                throw new NotImplementedException();
                break;
            }

            case "random_friending_room":
            {
                Room room = RoomManager.GetActive().ToList().Random();
                router.GetComposer <RoomForwardMessageComposer>().Compose(session, room.Data.Id);
                break;
            }
            }
        }
Ejemplo n.º 26
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            string type = request.GetString();

            router.GetComposer <SellablePetBreedsMessageComposer>().Compose(session, type);
        }
Ejemplo n.º 27
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            string motto = message.GetString();

            // TODO Filter!
            session.Info.Motto = motto;

            UserRepository.Save(session.Info);

            if (session.Room == null)
            {
                return;
            }

            session.Room.EachUser(
                (roomSession) =>
            {
                router.GetComposer <UpdateUserDataMessageComposer>()
                .Compose(roomSession, session.Info, session.RoomEntity.Id);
            }
                );

            AchievementManager.ProgressUserAchievement(session, ProfileAchievement.Motto);
        }
Ejemplo n.º 28
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            int selectType = request.GetInteger();
            int startIndex = request.GetInteger();

            router.GetComposer <GroupForumListingsMessageComposer>().Compose(session, selectType, startIndex);
        }
Ejemplo n.º 29
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            string badgeCode = message.GetString();
            bool   hasBadge  = session.Info.Badges.HasBadge(badgeCode);

            router.GetComposer <SendCampaignBadgeMessageComposer>().Compose(session, badgeCode, hasBadge);
        }
Ejemplo n.º 30
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage message,
                                           Yupi.Protocol.IRouter router)
        {
            Room room = session.Room;

            if (session.Room == null || session.GuideOtherUser == null)
            {
                return;
            }

            router.GetComposer <OnGuideSessionInvitedToGuideRoomMessageComposer>()
            .Compose(session.GuideOtherUser, room.Data.Id, room.Data.Name);

            // TODO Is this really required
            router.GetComposer <OnGuideSessionInvitedToGuideRoomMessageComposer>()
            .Compose(session, room.Data.Id, room.Data.Name);
        }