示例#1
0
		public DatabaseClient(DatabaseManager _Manager)
		{
			Manager = _Manager;
			Connection = new MySqlConnection(_Manager.ConnectionString);
			Command = this.Connection.CreateCommand();
			Connection.Open();
		}
示例#2
0
 public static void Destroy()
 {
     Program.DeleteMenu(Program.GetSystemMenu(Program.GetConsoleWindow(), true), Program.SC_CLOSE, Program.MF_BYCOMMAND);
     Logging.WriteLine("Destroying EssentialEmu environment...");
     if (Essential.GetGame() != null)
     {
         Essential.GetGame().ContinueLoading();
         Essential.Internal_Game = null;
     }
     if (Essential.GetSocketsManager() != null)
     {
         Logging.WriteLine("Destroying connection manager.");
         Essential.GetSocketsManager().method_3().method_2();
         //Essential.smethod_14().Destroy();
         Essential.GetSocketsManager().method_0();
         Essential.SocketsManager = null;
     }
     if (Essential.GetDatabase() != null)
     {
         try
         {
             Logging.WriteLine("Destroying database manager.");
             MySqlConnection.ClearAllPools();
             Essential.DatabaseManager = null;
         }
         catch
         {
         }
     }
     Logging.WriteLine("Uninitialized successfully. Closing.");
 }
示例#3
0
        internal static void Destroy(string string_8, bool ExitWhenDone, bool waitExit = false)
        {
            Program.DeleteMenu(Program.GetSystemMenu(Program.GetConsoleWindow(), true), Program.SC_CLOSE, Program.MF_BYCOMMAND);
            try
            {
                Internal_Game.StopGameLoop();
            }
            catch { }
            try
            {
                if (Essential.GetPacketManager() != null)
                {
                    Essential.GetPacketManager().Clear();
                }
            }
            catch { }
            if (string_8 != "")
            {
                if (Essential.bool_1)
                {
                    return;
                }
                Logging.Disable();
                Essential.smethod_17("ATTENTION:\r\nThe server is shutting down. All furniture placed in rooms/traded/bought after this message is on your own responsibillity.");
                Essential.bool_1 = true;
                Console.WriteLine("Server shutting down...");
                try
                {
                    Essential.Internal_Game.GetRoomManager().method_4();
                }
                catch
                {
                }
                try
                {
                    Essential.GetSocketsManager().method_3().method_1();
                    //Essential.smethod_14().Destroy();
                    Essential.GetGame().GetClientManager().CloseAll();
                }
                catch
                {
                }
                try
                {
                    Console.WriteLine("Destroying database manager.");
                    MySqlConnection.ClearAllPools();
                    Essential.DatabaseManager = null;
                }
                catch
                {
                }
                Console.WriteLine("System disposed, goodbye!");
            }
            else
            {
                Logging.Disable();
                Essential.bool_1 = true;
                try
                {
                    if (Essential.Internal_Game != null && Essential.Internal_Game.GetRoomManager() != null)
                    {
                        Essential.Internal_Game.GetRoomManager().UnloadAllRooms();
                        Essential.Internal_Game.GetRoomManager().method_4();
                    }
                }
                catch
                {
                }
                try
                {
                    if (Essential.GetSocketsManager() != null)
                    {
                        Essential.GetSocketsManager().method_3().method_1();
                        //Essential.smethod_14().Destroy();
                        Essential.GetGame().GetClientManager().CloseAll();
                    }
                }
                catch
                {
                }
                if (SocketsManager != null)
                {
                    //Essential.ConnectionManage.method_7();
                }
                if (Essential.Internal_Game != null)
                {
                    Essential.Internal_Game.ContinueLoading();
                }
                Console.WriteLine(string_8);
            }
            if (ExitWhenDone)
            {
                if (waitExit)
                {
                    Console.WriteLine("Press any key to exit..");
                    Console.ReadKey();
                }

                Environment.Exit(0);
            }
        }
示例#4
0
        public void Initialize()
        {
            Essential.consoleWriter = new ConsoleWriter(Console.Out);
            Console.SetOut(Essential.consoleWriter);
            try
            {
                Console.WindowWidth = 130;
                Console.WindowHeight = 36;
            }
            catch { }
            Essential.ServerStarted = DateTime.Now;
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine();
            Console.WriteLine(@"                                          ______                    _   _       _ ");
            Console.WriteLine(@"                                         |  ____|                  | | (_)     | |");
            Console.WriteLine(@"                                         | |__   ___ ___  ___ _ __ | |_ _  __ _| |");
            Console.WriteLine(@"                                         |  __| / __/ __|/ _ \ '_ \| __| |/ _` | |");
            Console.WriteLine(@"                                         | |____\__ \__ \  __/ | | | |_| | (_| | |");
            Console.WriteLine(@"                                         |______|___/___/\___|_| |_|\__|_|\__,_|_|");
            Console.WriteLine();
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("                                         Essential Emulator Build " + Build + " by " + Creator);
            Console.WriteLine();
            Console.WriteLine("                         Credits to: Meth0d (Uber), Sojobo (Phoenix), Juniori (GTE) & Rootkit (Essential)");
            Console.WriteLine();
            Console.ResetColor();
            try
            {
                Essential.Configuration = new ConfigurationData("config.conf");
                DateTime now = DateTime.Now;
                try
                {
                    Essential.SWFDirectory = Essential.GetConfig().data["web.api.furni.hof_furni"];
                }
                catch { }
                if (!Directory.Exists("API"))
                    Directory.CreateDirectory("API");

                DatabaseServer dbServer = new DatabaseServer(Essential.GetConfig().data["db.hostname"], uint.Parse(Essential.GetConfig().data["db.port"]), Essential.GetConfig().data["db.username"], Essential.GetConfig().data["db.password"]);
                Database database = new Database(Essential.GetConfig().data["db.name"], uint.Parse(Essential.GetConfig().data["db.pool.minsize"]), uint.Parse(Essential.GetConfig().data["db.pool.maxsize"]));
                Essential.DatabaseManager = new DatabaseManager(dbServer, database);
                GroupsPartsData.InitGroups();
                try
                {
                    using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                    {
                        dbClient.ExecuteQuery("SET @@global.sql_mode= '';");
                        dbClient.ExecuteQuery("UPDATE users SET online = '0'");
                        dbClient.ExecuteQuery("UPDATE rooms SET users_now = '0'");
                    }
                    Essential.Internal_Game.ContinueLoading();
                }
                catch { }

                Essential.Internal_Game = new Game(int.Parse(Essential.GetConfig().data["game.tcp.conlimit"]));

                Essential.PacketManager = new PacketManager();
                Essential.PacketManager.Load();
                Essential.mhandler = new MobileHandler();
                Essential.mhandler.Load();
                Console.WriteLine(Essential.PacketManager.Count + " Packets loaded!");
                Essential.antiAdSystem = new AntiAd();
                Essential.MusListener = new MusListener(Essential.GetConfig().data["mus.tcp.bindip"], int.Parse(Essential.GetConfig().data["mus.tcp.port"]), Essential.GetConfig().data["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20);
                Essential.SocketsManager = new SocketsManager(Essential.GetConfig().data["game.tcp.bindip"], int.Parse(Essential.GetConfig().data["game.tcp.port"]), int.Parse(Essential.GetConfig().data["game.tcp.conlimit"]));
                //ConnectionManage = new ConnectionHandeling(Essential.GetConfig().data["game.tcp.port"], int.Parse(Essential.GetConfig().data["game.tcp.conlimit"]), int.Parse(Essential.GetConfig().data["game.tcp.conlimit"]), true);
               Essential.HeadImagerURL = Essential.GetConfig().data["eventstream.imager.url"];
                using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                {
                    dbClient.ExecuteQuery("UPDATE server_status SET bannerdata='" + EssentialEnvironment.globalCrypto.Prime + ":" + EssentialEnvironment.globalCrypto.Generator + "';");
                }
                Essential.SocketsManager.method_3().method_0();
                webSocketServerManager = new WebSocketServerManager(Essential.GetConfig().data["websocket.url"]);
                Console.WriteLine("Server started at " + Essential.GetConfig().data["websocket.url"]);
                webManager = new WebManager();
                TimeSpan timeSpan = DateTime.Now - now;
                Logging.WriteLine(string.Concat(new object[]
				    {
					    "Server -> READY! (",
					    timeSpan.Seconds,
					    " s, ",
					    timeSpan.Milliseconds,
					    " ms)"
				    }));
                using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                {
                    dbClient.ExecuteQuery("UPDATE server_status SET server_started='" + Convert.ToInt32(GetUnixTimestamp()) + "'");
                }
                Console.Beep();
            }
            catch (KeyNotFoundException KeyNotFoundException)
            {
                Logging.WriteLine("Failed to boot, key not found: " + KeyNotFoundException);
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                Essential.Destroy();
            }
            catch (InvalidOperationException ex)
            {
                Logging.WriteLine("Failed to initialize EssentialEmulator: " + ex.Message);
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                Essential.Destroy();
            }
        }