Esempio n. 1
0
        /// <summary>
        /// Initializes the Ion server environment.
        /// </summary>
        public static void Initialize()
        {
            mLog.MinimumLogImportancy = LogType.Debug;
            mLog.WriteLine("Initializing Ion environment.");

            try
            {
                // Try to initialize configuration
                try
                {
                    mConfig = ConfigurationModule.LoadFromFile("settings.ini");
                }
                catch (FileNotFoundException ex)
                {
                    mLog.WriteError("Failed to load configuration file, exception message was: " + ex.Message);
                    IonEnvironment.Destroy();
                    return;
                }

                // Initialize database and test a connection by getting & releasing it
                DatabaseServer pDatabaseServer = new DatabaseServer(
                    IonEnvironment.Configuration["db1.server.host"],
                    IonEnvironment.Configuration.TryParseUInt32("db1.server.port"),
                    IonEnvironment.Configuration["db1.server.uid"],
                    IonEnvironment.Configuration["db1.server.pwd"]);

                Database pDatabase = new Database(
                    IonEnvironment.Configuration["db1.name"],
                    IonEnvironment.Configuration.TryParseUInt32("db1.minpoolsize"),
                    IonEnvironment.Configuration.TryParseUInt32("db1.maxpoolsize"));

                mDatabaseManager = new DatabaseManager(pDatabaseServer, pDatabase);
                mDatabaseManager.SetClientAmount(2);
                mDatabaseManager.ReleaseClient(mDatabaseManager.GetClient().Handle);
                mDatabaseManager.StartMonitor();

                // Initialize TCP listener
                mTcconnectionManager = new IonTcpConnectionManager(
                    IonEnvironment.Configuration["net.tcp.localip"],
                    IonEnvironment.Configuration.TryParseInt32("net.tcp.port"),
                    IonEnvironment.Configuration.TryParseInt32("net.tcp.maxcon"));
                mTcconnectionManager.GetListener().Start();


                // Try to initialize Habbo Hotel
                mHabboHotel = new Ion.HabboHotel.HabboHotel();

                IonEnvironment.GetLog().WriteLine("Initialized Ion environment.");
            }
            catch (Exception ex) // Catch all other exceptions
            {
                mLog.WriteError("Unhandled exception occurred during initialization of Ion environment. Exception message: " + ex.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes the Ion server environment.
        /// </summary>
        public static void Initialize()
        {
            mLog.MinimumLogImportancy = LogType.Debug;
            Console.WriteLine(" [**] --> Initializing Aleeda environment.");

            DefaultEncoding = Encoding.Default;

            try
            {
                // Try to initialize configuration
                try
                {
                    mConfig = ConfigurationModule.LoadFromFile("settings.ini");
                }
                catch (FileNotFoundException ex)
                {
                    mLog.WriteError("Failed to load configuration file, exception message was: " + ex.Message);
                    AleedaEnvironment.Destroy();
                    return;
                }

                // Initialize database and test a connection by getting & releasing it
                DatabaseServer pDatabaseServer = new DatabaseServer(
                    AleedaEnvironment.Configuration["db1.server.host"],
                    AleedaEnvironment.Configuration.TryParseUInt32("db1.server.port"),
                    AleedaEnvironment.Configuration["db1.server.uid"],
                    AleedaEnvironment.Configuration["db1.server.pwd"]);

                Database pDatabase = new Database(
                    AleedaEnvironment.Configuration["db1.name"],
                    AleedaEnvironment.Configuration.TryParseUInt32("db1.minpoolsize"),
                    AleedaEnvironment.Configuration.TryParseUInt32("db1.maxpoolsize"));

                mDatabaseManager = new DatabaseManager(pDatabaseServer, pDatabase);
                mDatabaseManager.SetClientAmount(2);
                mDatabaseManager.ReleaseClient(mDatabaseManager.GetClient().Handle);
                mDatabaseManager.StartMonitor();

                // Initialize TCP listener
                mTcconnectionManager = new IonTcpConnectionManager(
                    AleedaEnvironment.Configuration.TryParseInt32("net.tcp.port"),
                    AleedaEnvironment.Configuration.TryParseInt32("net.tcp.maxcon"));
                mTcconnectionManager.GetListener().Start();


                // Try to initialize Habbo Hotel

                using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
                {
                    /*for (int i = 0; i < 10000000000; i++)
                     * {
                     *  dbClient.ExecuteQuery("INSERT INTO private_rooms (name, rating, description, ownerid, status, tags, thumbnail, petsAllowed, category, model, wallpaper, floorpaper, landscape) VALUES ('Meep','0' ,'New room!', 'Quackie', '0', '', 'HHHH', '1', '0', 'model_a', '000', '000', '0.0')");
                     * }*/
                }


                mHabboHotel = new Aleeda.HabboHotel.HabboHotel();
                mGetCache   = new HabboHotel.Cache.GetCache();

                //HabboHotel.Cache.Privilege.BootUp();

                using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
                {
                    dbClient.ExecuteQuery("UPDATE users SET online = '0'");
                    dbClient.ExecuteQuery("UPDATE users SET flat = '0'");
                }

                Console.WriteLine(" [**] --> Initialized Aleeda environment.");

                GC.Collect();
            }
            catch (Exception ex) // Catch all other exceptions
            {
                mLog.WriteError("Unhandled exception occurred during initialization of Aleeda environment. Exception message: " + ex);
            }
        }