示例#1
0
        public static void PerformShutDown(bool restart)
        {
            Console.Clear();
            log.Info("Apagando el servidor...");
            Console.Title = "CLOUD: APAGANDO!";

            ShutdownStarted = true;

            GetGame().GetClientManager().SendMessage(new BroadcastMessageAlertComposer(GetGame().GetLanguageManager().TryGetValue("server.shutdown.message")));
            GetGame().StopGameLoop();
            System.Threading.Thread.Sleep(2500);
            GetConnectionManager().Destroy();             //Stop listening.
            GetGame().GetPacketManager().UnregisterAll(); //Unregister the packets.
            GetGame().GetPacketManager().WaitForAllToComplete();
            GetGame().GetClientManager().CloseAll();      //Close all connections
            GetGame().GetRoomManager().Dispose();         //Stop the game loop.

            GetConnectionManager().Destroy();

            using (IQueryAdapter dbClient = _manager.GetQueryReactor())
            {
                dbClient.runFastQuery("TRUNCATE `catalog_marketplace_data`");
                dbClient.runFastQuery("UPDATE `users` SET online = '0', `auth_ticket` = NULL");
                dbClient.runFastQuery("UPDATE `rooms` SET `users_now` = '0'");
            }

            _connectionManager.Destroy();
            _game.Destroy();

            log.Info("Cloud Server Fue Apagado con Exito.");

            if (!restart)
            {
                log.WarnFormat("Apagado Completo. Presione una tecla para continuar...", ConsoleColor.DarkRed);
            }

            if (!restart)
            {
                Console.ReadKey();
            }

            IsLive = false;

            if (restart)
            {
                Process.Start(Assembly.GetEntryAssembly().Location);
            }

            if (restart)
            {
                Console.WriteLine("Reiniciando...");
            }
            else
            {
                Console.WriteLine("Cerrando...");
            }

            System.Threading.Thread.Sleep(1000);
            Environment.Exit(0);
        }
示例#2
0
        public static void Dispose(object sender, UnhandledExceptionEventArgs args)
        {
            Console.Clear();
            Console.Title = "PLUS EMULATOR: SHUTTING DOWN!";

            _connectionManager.Destroy();

            GameContext.Dispose();
            Thread.Sleep(5000);

            DatabaseManager.ResetDatabase();

            Thread.Sleep(1000);
            Environment.Exit(0);
        }
示例#3
0
        internal static void PreformShutDown(bool ExitWhenDone)
        {
            if (ShutdownInitiated || !isLive)
            {
                return;
            }

            StringBuilder builder = new StringBuilder();

            DateTime ShutdownStart = DateTime.Now;

            DateTime MessaMessage = DateTime.Now;

            ShutdownInitiated = true;

            SendMassMessage(LanguageLocale.GetValue("shutdown.alert"));
            AppendTimeStampWithComment(ref builder, MessaMessage, "Hotel pre-warning");

            Game.StopGameLoop();
            Console.Write("Game loop stopped");

            DateTime ConnectionClose = DateTime.Now;

            Console.WriteLine("Server shutting down...");
            Console.Title = "<<- SERVER SHUTDOWN ->>";

            GetConnectionManager().Destroy();
            AppendTimeStampWithComment(ref builder, ConnectionClose, "Socket close");

            DateTime sConnectionClose = DateTime.Now;

            GetGame().GetClientManager().CloseAll();
            AppendTimeStampWithComment(ref builder, sConnectionClose, "Furni pre-save and connection close");

            DateTime RoomRemove = DateTime.Now;

            Console.WriteLine("<<- SERVER SHUTDOWN ->> ROOM SAVE");
            Game.GetRoomManager().RemoveAllRooms();
            AppendTimeStampWithComment(ref builder, RoomRemove, "Room destructor");

            DateTime DbSave = DateTime.Now;

            using (IQueryAdapter dbClient = manager.getQueryreactor())
            {
                // dbClient.runFastQuery("TRUNCATE TABLE user_tickets");
                dbClient.runFastQuery("TRUNCATE TABLE user_online");
                dbClient.runFastQuery("TRUNCATE TABLE room_active");
                dbClient.runFastQuery("UPDATE users SET online = 0");
                dbClient.runFastQuery("UPDATE rooms SET users_now = 0");
            }
            AppendTimeStampWithComment(ref builder, DbSave, "Database pre-save");

            DateTime connectionShutdown = DateTime.Now;

            ConnectionManager.Destroy();
            AppendTimeStampWithComment(ref builder, connectionShutdown, "Connection shutdown");

            DateTime gameDestroy = DateTime.Now;

            Game.Destroy();
            AppendTimeStampWithComment(ref builder, gameDestroy, "Game destroy");

            DateTime databaseDeconstructor = DateTime.Now;

            try
            {
                Console.WriteLine("Destroying database manager.");

                manager.destroy();
            }
            catch { }
            AppendTimeStampWithComment(ref builder, databaseDeconstructor, "Database shutdown");

            TimeSpan timeUsedOnShutdown = DateTime.Now - ShutdownStart;

            builder.AppendLine("Total time on shutdown " + TimeSpanToString(timeUsedOnShutdown));
            builder.AppendLine("You have reached ==> [END OF SESSION]");
            builder.AppendLine();
            builder.AppendLine();
            builder.AppendLine();

            Logging.LogShutdown(builder);

            Console.WriteLine("System disposed, goodbye!");
            if (ExitWhenDone)
            {
                Environment.Exit(Environment.ExitCode);
            }
        }
示例#4
0
文件: Plus.cs 项目: Mereos/HabboEMU
        /// <summary>
        /// Shutdown the Emulator
        /// </summary>
        /// <param name="restart">if set to <c>true</c> [restart].</param>
        /// Set a Different Message in Hotel
        internal static void PerformShutDown(bool restart)
        {
            var now = DateTime.Now;

            Cache.StopProcess();

            ShutdownStarted = true;

            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));

            serverMessage.AppendString("disconnection");
            serverMessage.AppendInteger(2);
            serverMessage.AppendString("title");
            serverMessage.AppendString("Emulator Shutting down");
            serverMessage.AppendString("message");
            serverMessage.AppendString("<b>A technician has applied new updates / fixes, so the hotel is shutting down for these changes to take effect! It will automatically come back in a few seconds! So Long!");
            GetGame().GetClientManager().QueueBroadcaseMessage(serverMessage);

            System.Threading.Thread.Sleep(3000);

            _game.StopGameLoop();
            _game.GetRoomManager().RemoveAllRooms();
            GetGame().GetClientManager().CloseAll();

            GetConnectionManager().Destroy();

            foreach (Guild group in _game.GetGroupManager().Groups.Values)
            {
                group.UpdateForum();
            }

            using (var queryReactor = Manager.GetQueryReactor())
            {
                queryReactor.RunFastQuery("UPDATE users SET online = '0'");
                queryReactor.RunFastQuery("UPDATE rooms_data SET users_now = 0");
                queryReactor.RunFastQuery("UPDATE server_settings SET value = '0' WHERE variable = 'status'");
            }

            _connectionManager.Destroy();
            _game.Destroy();

            try
            {
                Manager.Destroy();
                Out.WriteLine("Game Manager destroyed", "", ConsoleColor.Red);
            }
            catch (Exception e)
            {
                Writer.Writer.LogException("Plus.cs PerformShutDown GameManager" + e);
            }

            TimeSpan timeUsedOnShutdown = DateTime.Now - now;

            Console.WriteLine(" >> CityRP Emulator Successfully Shutdown <<");
            IsLive = false;

            if (restart)
            {
                Process.Start(Assembly.GetEntryAssembly().Location);
            }
            else
            {
                System.Threading.Thread.Sleep(2000);
            }

            Environment.Exit(0);
        }