コード例 #1
0
ファイル: DatabaseClient.cs プロジェクト: neto737/Phoenix_3.0
 public DatabaseClient(DatabaseManager _Manager)
 {
     this.Manager = _Manager;
     this.Connection = new MySqlConnection(_Manager.ConnectionString);
     this.Command = this.Connection.CreateCommand();
     this.Connection.Open();
 }
コード例 #2
0
 public static void Destroy()
 {
     Logging.WriteLine("Destroying PhoenixEmu environment...");
     if (GetGame() != null)
     {
         GetGame().Destroy();
         Game = null;
     }
     if (GetConnectionManager() != null)
     {
         Logging.WriteLine("Destroying connection manager.");
         GetConnectionManager().GetListener().Destroy();
         GetConnectionManager().DestroyManager();
         ConnectionManager = null;
     }
     if (GetDatabase() != null)
     {
         try
         {
             Logging.WriteLine("Destroying database manager.");
             MySqlConnection.ClearAllPools();
             DatabaseManager = null;
         }
         catch { }
     }
     Logging.WriteLine("Uninitialized successfully. Closing.");
 }
コード例 #3
0
 internal static void PerformShutDown(string reason, bool ExitWhenDone)
 {
     GlobalClass.ShuttingDown = true;
     try
     {
         GetPacketManager().UnregisterPackets();
     }
     catch { }
     if (reason != "")
     {
         if (ShutdownInitiated)
         {
             return;
         }
         Console.WriteLine(reason);
         Logging.DisablePrimaryWriting();
         SendMassMessage("ATTENTION:\r\nThe server is shutting down. All furniture placed in rooms/traded/bought after this message is on your own responsibillity.");
         ShutdownInitiated = true;
         Console.WriteLine("Server shutting down...");
         try
         {
             Game.GetRoomManager().RemoveAllRooms();
         }
         catch { }
         try
         {
             GetConnectionManager().GetListener().Stop();
             GetGame().GetClientManager().CloseAll();
         }
         catch { }
         try
         {
             using (DatabaseClient adapter = GetDatabase().GetClient())
             {
                 adapter.ExecuteQuery("UPDATE users SET online = '0'");
                 adapter.ExecuteQuery("UPDATE rooms SET users_now = '0'");
             }
             ConnectionManager.Shutdown();
             Game.Destroy();
         }
         catch { }
         try
         {
             Console.WriteLine("Destroying database manager.");
             MySqlConnection.ClearAllPools();
             DatabaseManager = null;
         }
         catch { }
         Console.WriteLine("System disposed, goodbye!");
     }
     else
     {
         Logging.DisablePrimaryWriting();
         ShutdownInitiated = true;
         try
         {
             Game.GetRoomManager().RemoveAllRooms();
         }
         catch { }
         try
         {
             GetConnectionManager().GetListener().Stop();
             GetGame().GetClientManager().CloseAll();
         }
         catch { }
         ConnectionManager.Shutdown();
         Game.Destroy();
         Console.WriteLine(reason);
     }
     if (ExitWhenDone)
     {
         Environment.Exit(0);
     }
 }
コード例 #4
0
        public void Initialize()
        {
            ServerStarted = DateTime.Now;
            TextManager.WritePhoenix();
            try
            {
                Configuration = new ConfigurationData("config.conf");
                DateTime now = DateTime.Now;

                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Gray;

                DatabaseServer server = new DatabaseServer(GetConfig().data["db.hostname"], uint.Parse(GetConfig().data["db.port"]), GetConfig().data["db.username"], GetConfig().data["db.password"]);
                Database database = new Database(GetConfig().data["db.name"], uint.Parse(GetConfig().data["db.pool.minsize"]), uint.Parse(GetConfig().data["db.pool.maxsize"]));
                DatabaseManager = new DatabaseManager(server, database);
                Game = new Game(int.Parse(GetConfig().data["game.tcp.conlimit"]));

                Messages = new MessageHandler();
                Messages.RegisterHandshake();
                Messages.RegisterMessenger();
                Messages.RegisterNavigator();
                Messages.RegisterRoomsAction();
                Messages.RegisterRoomsAvatar();
                Messages.RegisterRoomsChat();
                Messages.RegisterRoomsEngine();
                Messages.RegisterRoomsFurniture();
                Messages.RegisterRoomsPets();
                Messages.RegisterRoomsSession();
                Messages.RegisterRoomsSettings();
                Messages.RegisterCatalog();
                Messages.RegisterMarketplace();
                Messages.RegisterRecycler();
                Messages.RegisterQuest();
                Messages.RegisterInventoryAchievements();
                Messages.RegisterInventoryAvatarFX();
                Messages.RegisterInventoryBadges();
                Messages.RegisterInventoryFurni();
                Messages.RegisterInventoryPurse();
                Messages.RegisterInventoryTrading();
                Messages.RegisterAvatar();
                Messages.RegisterUsers();
                Messages.RegisterRegister();
                Messages.RegisterHelp();
                Messages.RegisterSound();
                Messages.RegisterWired();
                Messages.RegisterFriendStream(); //NEW!

                MusListener = new MusSocket(GetConfig().data["mus.tcp.bindip"], int.Parse(GetConfig().data["mus.tcp.port"]), GetConfig().data["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20);
                ConnectionManager = new TcpConnectionManager(GetConfig().data["game.tcp.bindip"], int.Parse(GetConfig().data["game.tcp.port"]), int.Parse(GetConfig().data["game.tcp.conlimit"]));
                ConnectionManager.GetListener().Start();
                TimeSpan span = DateTime.Now - now;
                Logging.WriteLine(string.Concat(new object[] { "Server -> READY! (", span.Seconds, " s, ", span.Milliseconds, " ms)" }));
                Console.Beep();
            }
            catch (KeyNotFoundException)
            {
                Logging.WriteLine("Failed to boot, key not found.");
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                Destroy();
            }
            catch (InvalidOperationException ex)
            {
                Logging.WriteLine("Failed to initialize PhoenixEmulator: " + ex.Message);
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                Destroy();
            }
        }