Ejemplo n.º 1
0
        /// <summary>
        /// Destroys the Ion server environment and exits the application.
        /// </summary>
        public static void Destroy()
        {
            IonEnvironment.GetLog().WriteLine("Destroying Ion environment.");

            // Destroy Habbo Hotel 8-) (and all inner modules etc)
            if (GetHabboHotel() != null)
            {
                GetHabboHotel().Destroy();
            }

            // Clear connections
            if (GetTcpConnections() != null)
            {
                IonEnvironment.GetLog().WriteLine("Destroying TCP connection manager.");
                GetTcpConnections().GetListener().Stop();
                GetTcpConnections().GetListener().Destroy();
                GetTcpConnections().DestroyManager();
            }

            // Stop database
            if (GetDatabase() != null)
            {
                IonEnvironment.GetLog().WriteLine("Destroying database " + GetDatabase().ToString());
                GetDatabase().StopMonitor();
                GetDatabase().DestroyClients();
                GetDatabase().DestroyManager();
            }

            IonEnvironment.GetLog().WriteLine("Press a key to exit.");

            Console.ReadKey();
            System.Environment.Exit(0);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            Console.Title = "Ion: Habbo Hotel server emulation environment";
            Console.Beep();

            IonEnvironment.Initialize();

            // Input loop
            while (true)
            {
                Console.ReadKey(true);

                IonEnvironment.GetLog().WriteInformation("Shutting down...");
                IonEnvironment.GetLog().WriteInformation("Press a key to exit.");
                Console.ReadKey(true);
                IonEnvironment.Destroy();
            }
        }