示例#1
0
		public DatabaseManager(DatabaseServer _Server, Database _Database)
		{
			this.Server = _Server;
			this.Database = _Database;
		}
示例#2
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();
            }
        }