internal static void ProcessEncryptionRequest(Habbo sender, IncomingMessage message)
 {
     new MSetupEncryption
         {
             UnknownA = false
         }.Send(sender);
 }
Example #2
0
        private List<FriendUpdate> fUpdateList; // The updates to send next time SendUpdates() is called.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructs a new Messenger.
        /// </summary>
        /// <param name="User">The user who's messenger to manage.</param>
        /// <param name="BlockFlags">Not done yet</param>
        internal Messenger(Habbo User, byte BlockFlags)
        {
            this.fHabbo = User;
            this.fBlockFlags = BlockFlags;                  // TODO: Add BlockFlags

            this.fUpdateList = new List<FriendUpdate>();    // Prepare to store update data.
        }
        private static void ProcessRequestCategoryListings(Habbo sender, IncomingMessage message)
        {
            bool excludeFullRooms = message.PopWiredBoolean();
            int categoryID = message.PopWiredInt32();

            Category category = CoreManager.ServerCore.GetNavigator().GetCategory(categoryID);

            if (category == null)
                new MNavigatorCategoryListing // TODO: Remove this. Maybe even throw an exception?
                    {
                        ID = categoryID,
                        ExcludeFullRooms = excludeFullRooms,
                        Name = "Non-Existant Category",
                        ParentID = categoryID,
                        IsPublicCategory = true,
                        Listings = new Listing[0],
                        UnknownA = 0,
                        UnknownB = 10000,
                        UnknownC = 0
                    }.Send(sender);
            else
                new MNavigatorCategoryListing
                {
                    ID = categoryID,
                    ExcludeFullRooms = excludeFullRooms,
                    Name = category.Name,
                    ParentID = (category.PrimaryCategory != null ? category.PrimaryCategory.ID : category.ID),
                    IsPublicCategory = category.IsPublicCategory,
                    Listings = category.GetListings(),

                    UnknownA = 0,
                    UnknownB = 10000,
                    UnknownC = 0
                }.Send(sender);
        }
 internal static void ProcessPong(Habbo sender, IncomingMessage message)
 {
     HabboEventArgs eventArgs = new HabboEventArgs(sender);
     R36StandardStuff.EventFirer.Fire("habbo_pong:before", eventArgs);
     if (!eventArgs.IsCancelled)
         R36StandardStuff.EventFirer.Fire("habbo_pong:after", eventArgs);
 }
 internal static void ProcessSessionRequest(Habbo sender, IncomingMessage message)
 {
     new MSessionParams
         {
             A = 9,
             B = 0,
             C = 0,
             D = 1,
             E = 1,
             F = 3,
             G = 0,
             H = 2,
             I = 1,
             J = 4,
             K = 0,
             L = 5,
             DateFormat = "dd-MM-yyyy",
             M = "",
             N = 7,
             O = false,
             P = 8,
             URL = "http://null",
             Q = "",
             R = 9,
             S = false
         }.Send(sender);
 }
 internal static void ProcessCurrentDateRequest(Habbo sender, IncomingMessage message)
 {
     new MCurrentDate
     {
         Date = DateTime.Today
     }.Send(sender);
 }
        public IEnumerable<Category> GetCategories(Habbo habbo)
        {
            CategoryHabboEventArgs eventArgs = new CategoryHabboEventArgs(habbo);
            _pluginInstance.EventFirer.Fire(_pluginInstance.Id + ":habbo_category_request:before", eventArgs);
            _pluginInstance.EventFirer.Fire(_pluginInstance.Id + ":habbo_category_request:after", eventArgs);

            return eventArgs.GetCategories();
        }
        private static void ProcessRequestOwnRoomListing(Habbo sender, IncomingMessage message)
        {
            // TODO: Database tables for rooms.

            new MOwnRoomListing
            {
                Rooms = null
            }.Send(sender);
        }
Example #9
0
        internal PacketProcessor(Habbo User)
        {
            this.fUser = User;

            IonTcpConnection Connection = this.fUser.GetConnection();

            Connection.AddHandler(196, PacketHandlerPriority.DefaultAction, new PacketHandler(Process_Pong));
            Connection.AddHandler(512, PacketHandlerPriority.DefaultAction, new PacketHandler(Process_Disconnect));
        }
Example #10
0
 /// <summary>
 /// Checks if a given user has requested to be friends with this user.
 /// </summary>
 /// <returns>Returns true if a friend request exists, false otherwise.</returns>
 public bool HasRequestFrom(Habbo User)
 {
     /*
     using (DatabaseClient dbClient = Core.GetDatabaseManager().GetClient())
     {
         dbClient.AddParamWithValue("localuserid", this.fUser.GetID());
         dbClient.AddParamWithValue("remoteuserid", User.GetID());
         return dbClient.ReadExist("SELECT 0 FROM messenger_friendrequests WHERE (userid_to = @me AND userid_from = @them AND userid_to > 0 AND userid_from > 0) OR (userid_to = @them AND userid_from = @me AND userid_to > 0 AND userid_from > 0)");
     }*/
     return false;
 }
Example #11
0
File: Friend.cs Project: habb0/IHI
        private bool fWasLoggedIn; // Was the user logged in last Update()?

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Construct a new Friend object.
        /// </summary>
        /// <param name="User">The User who is a Friend.</param>
        /// <param name="LocalCategory">The category ID that this Friend appears in.</param>
        /// <param name="RemoteCategory">The category ID that this Friend appears in for the friend.</param>
        public Friend(Habbo Habbo, int LocalCategory, int RemoteCategory)
        {
            this.fHabbo = Habbo;
            this.fLocalCategory = LocalCategory;
            this.fRemoteCategory = RemoteCategory;

            this.fWasLoggedIn = false;
            this.fWasInRoom = false;

            Update(); // Ensure the Friend object is up to date before use.
        }
Example #12
0
File: Friend.cs Project: habb0/IHI
        public Friend(Habbo Habbo, int? LocalCategory, int? RemoteCategory)
        {
            this.fHabbo = Habbo;

            if (LocalCategory.HasValue)
                this.fLocalCategory = LocalCategory.Value;
            if (RemoteCategory.HasValue)
                this.fRemoteCategory = RemoteCategory.Value;

            this.fWasLoggedIn = false;
            this.fWasInRoom = false;
        }
Example #13
0
        private static void Process_RequestSubscriptionData(Habbo Sender, IncomingMessage Message)
        {
            string SubscriptionName = Message.PopPrefixedString();

            SubscriptionData Data = new SubscriptionData(Sender, SubscriptionName);

            // 86400    = 24 hours in seconds.
            // 2678400  = 31 days in seconds.
            byte RemainingFullMonths = (byte)(Data.GetRemainingSeconds() / 2678400);
            byte ExpiredFullMonths = (byte)(Data.GetExpiredSeconds() / 2678400);
            byte ExpiredMonthDays = (byte)((Data.GetExpiredSeconds() % 2678400) / 86400);

            Sender.GetPacketSender().Send_SubscriptionInfo(SubscriptionName, ExpiredMonthDays, ExpiredFullMonths, RemainingFullMonths, Data.IsActive());
        }
Example #14
0
 private void SafeInvoke(GameSocketMessageHandler handler, Habbo sender, IncomingMessage message)
 {
     try
     {
         handler(sender, message);
     }
     catch (Exception e)
     {
         sender.Socket.Disconnect("Unhandled Exception in packet handler");
         string dumpPath = CoreManager.ServerCore.DumpException(e);
         CoreManager.ServerCore.ConsoleManager.Error("Event Handler", "An unhandled exception from a packet handler has been caught and the socket has been closed!");
         CoreManager.ServerCore.ConsoleManager.Error("Event Handler", "    An exception dump has been saved to " + dumpPath);
     }
 }
Example #15
0
 internal static void ProcessAccountDetailsRequest(Habbo sender, IncomingMessage message)
 {
     new MAccountDetails
     {
         ConnectionId = 0,
         Username = sender.Username, // Should this be DisplayName
         Motto = sender.Motto,
         Figure = sender.Figure,
         UnknownA = "",
         UnknownB = 12,
         UnknownC = 0,
         UnknownD = 1
     }.Send(sender);
 }
 internal static void ProcessMessengerInit(Habbo sender, IncomingMessage message)
 {
     MessengerManager manager = CoreManager.ServerCore.GetMessengerManager();
     new MMessengerInit
     {
         BefriendablesToExclude = new HashSet<Befriendable>
         {
             manager.GetBefriendable(sender)
         },
         Categories = manager.GetCategories(sender),
         MaximumFriends = 200, // TODO: Make this controllable by plugins.
         UnknownA = 10,
         UnknownB = 20,
         UnknownC = 30,
         UnknownD = false
     }.Send(sender);
 }
        public MessengerObject(Habbo owner)
        {
            _categories = new Dictionary<int, Category>();
            _friends = new Dictionary<int, Friend>();
            _friendRequests = new Dictionary<int, IBefriendable>();

            Owner = owner;

            // TODO: Fix at later date
            /*
            if (Owner.GetPersistantVariable("Messenger.StalkBlock") != null)
                Owner.BlockStalking = true;
            if (Owner.GetPersistantVariable("Messenger.RequestBlock") != null)
                Owner.BlockRequests = true;
            if (Owner.GetPersistantVariable("Messenger.InviteBlock") != null)
                Owner.BlockInvites = true;
             */
        }
        public Befriendable GetBefriendable(Habbo habbo)
        {
            Befriendable befriendableInstance = habbo.InstanceStorage[_pluginInstance, "befriendable_instance"];

            if (befriendableInstance == null)
            {
                befriendableInstance = new Befriendable(
                    (() => habbo.Id),
                    (() => habbo.DisplayName),
                    (() => habbo.Motto),
                    (() => habbo.Figure),
                    (() => habbo.Position),
                    (() => habbo.LoggedIn),
                    (() => habbo.LastAccess));

                habbo.InstanceStorage[_pluginInstance, "befriendable_instance"] = befriendableInstance;
            }
            return befriendableInstance;
        }
Example #19
0
        public GameSocketMessageHandlers Invoke(Habbo sender, IncomingMessage message)
        {
            if (HighPriority != null)
                SafeInvoke(HighPriority, sender, message);

            if (message.Cancelled)
                return this;

            if (LowPriority != null)
                SafeInvoke(LowPriority, sender, message);

            if (message.Cancelled)
                return this;

            if (DefaultAction != null)
                SafeInvoke(DefaultAction, sender, message);

            if (Watcher != null)
                SafeInvoke(Watcher, sender, message);

            return this;
        }
Example #20
0
        // TODO: Check if it is worth adding an ID-Username cache.

        #endregion

        #region Methods

        #region Exposed Methods

        /// <summary>
        ///   Return a Habbo from the cache if possible.
        ///   If the Habbo is not cached then put it in the cache and return it.
        /// </summary>
        /// <param name = "username">The username of the Habbo to return.</param>
        public Habbo GetHabbo(string username)
        {
            lock (this)
            {
                // Is the ID cached for this username (and therefore the Habbo)?
                if (_usernameIDCache.ContainsKey(username))
                {
                    // Yes, get the cached Habbo.
                    Habbo cached = _habboCache[_usernameIDCache[username]].Target as Habbo;

                    // Has the cached Habbo been collected and removed from memory?
                    if (cached != null)
                    {
                        // No, return the cached copy.
                        return(cached);
                    }


                    // The cached Habbo has been collected and is no longer in memory...

                    // Remove the WeakReference to the cached Habbo.
                    _habboCache.Remove(_usernameIDCache[username]);
                    // Remove the cached Username and ID.
                    _usernameIDCache.Remove(username);
                }

                // Load the Habbo into memory from the database.
                Habbo theHabbo = new Habbo(username);

                // Yes, cache it.
                CacheHabbo(theHabbo);

                // Return the newly cached Habbo.
                return(theHabbo);
            }
        }
Example #21
0
        /// <summary>
        ///   Return a Habbo from the cache if possible.
        ///   If the Habbo is not cached then put it in the cache and return it.
        /// </summary>
        /// <param name = "username">The username of the Habbo to return.</param>
        public Habbo GetHabbo(string username)
        {
            lock (this)
            {
                // Is the ID cached for this username (and therefore the Habbo)?
                if (_usernameIDCache.ContainsKey(username))
                {
                    // Yes, get the cached Habbo.
                    Habbo cached = _habboCache[_usernameIDCache[username]].Target as Habbo;

                    // Has the cached Habbo been collected and removed from memory?
                    if (cached != null)
                        // No, return the cached copy.
                        return cached;

                    // The cached Habbo has been collected and is no longer in memory...

                    // Remove the WeakReference to the cached Habbo.
                    _habboCache.Remove(_usernameIDCache[username]);
                    // Remove the cached Username and ID.
                    _usernameIDCache.Remove(username);
                }

                // Load the Habbo into memory from the database.
                Habbo theHabbo = new Habbo(username);

                // Yes, cache it.
                CacheHabbo(theHabbo);

                // Return the newly cached Habbo.
                return theHabbo;
            }
        }
Example #22
0
 /// <summary>
 ///   Add a Habbo into the cache.
 /// </summary>
 /// <param name = "theHabbo">The Habbo to cache.</param>
 private void CacheHabbo(Habbo theHabbo)
 {
     lock (this)
     {
         // Cache the Habbo.
         _habboCache.Add(theHabbo.GetID(), new WeakReference(theHabbo));
         // Cache the Username-ID.
         _usernameIDCache.Add(theHabbo.GetUsername(), theHabbo.GetID());
     }
 }
Example #23
0
        /// <summary>
        ///   Return a Habbo from the cache if possible.
        ///   If the Habbo is not cached then put it in the cache and return it.
        ///   FYI: If the Habbo is not cached then this the Habbo will be created from the data provided.
        /// </summary>
        /// <param name = "habbo">The database result of the Habbo to return.</param>
        public Habbo GetHabbo(Database.Habbo habbo)
        {
            lock (this)
            {
                // Is this Habbo already cached?
                if (_habboCache.ContainsKey(habbo.habbo_id))
                {
                    // Yes, get the cached Habbo.
                    Habbo cached = _habboCache[habbo.habbo_id].Target as Habbo;

                    // Has the cached Habbo been collected and removed from memory?
                    if (cached != null)
                        // No, return the cached copy.
                        return cached;

                    // Yes, we may as well do a full clean up here. We'll have to loop over it all anyway.
                    CleanUp(true);
                }

                // Load the Habbo into memory from the database.
                Habbo theHabbo = new Habbo(habbo);

                // Yes, cache it.
                CacheHabbo(theHabbo);

                // Return the newly cached Habbo.
                return theHabbo;
            }
        }
Example #24
0
 public HabboEventArgs(Habbo habbo)
 {
     Habbo = habbo;
 }
Example #25
0
        /// <summary>
        ///   Starts the Connection, prepares the received data buffer and waits for data.
        /// </summary>
        internal void Start()
        {
            _dataBuffer = new byte[ReceivedataBufferSize];
            _dataReceivedCallback = new AsyncCallback(DataReceived);
            _routeReceivedDataCallback = new RouteReceivedDataCallback(HandleConnectionData);

            Habbo = new Habbo(this);
            WaitForData();
        }
Example #26
0
 public SubscriptionData(Habbo habbo, string type)
 {
     Subscriber = habbo;
     Type = type;
 }
Example #27
0
 private void Process_DYNAMIC(Habbo Sender, IncomingMessage Message)
 {
     lock (this.fPacketLogs)
     {
         this.fPacketLogs.
             Append("<div class='packet'>").
             Append('[').
             Append(Message.GetID()).
             Append("] <u>").
             Append(Message.GetHeader()).
             Append("</u>").
             Append(Message.GetContentString()).
             Append("</div>");
     }
 }
        private static void ProcessRequestUsableCategoryListing(Habbo sender, IncomingMessage message)
        {
            // TODO: Permissions

            LibNav.Navigator navigator = CoreManager.ServerCore.GetNavigator();

            new MUsableGuestCategoryListing
            {
                Categories = navigator.GetChildren(navigator.GuestRoot, NavigatorTreeSearchMode.GuestOnly)
            }.Send(sender);
        }
        private static void ProcessRequestRecommendedRoomListing(Habbo sender, IncomingMessage message)
        {
            // TODO: Recommended Room API methods

            new MRecommendedRoomListing
            {
                RoomListings = new GuestRoomListing[0] // No recommended rooms for now.
            }.Send(sender);
        }
Example #30
0
 internal static void ProcessGroupStatusInit(Habbo sender, IncomingMessage message)
 {
     // Load group stuff
 }
Example #31
0
File: Habbo.cs Project: habb0/IHI
        public void LoginMerge(Habbo loggedInUser)
        {
            _connection = loggedInUser._connection;

            _connection.Habbo = this;
        }
        public GameSocketMessageHandlerInvoker Invoke(Habbo sender, IncomingMessage message)
        {
            lock (_handlers)
            {
                // Are there any handlers registered for this packet?
                if (!_handlers.ContainsKey(message.HeaderId))
                {
                    CoreManager.ServerCore.ConsoleManager.Warning("Game Socket Manager", "Unhandled HeaderID " + message.HeaderId + " (\"" + message.HeaderString + "\")");
                    // No, do nothing.
                    return this;
                }

                // Yes, let's invoke them.
                _handlers[message.HeaderId].Invoke(sender, message);
            }

            return this;
        }