/// <summary> /// Constructs a new database client with a given handle to a given database proxy. /// </summary> /// <param name="Handle">The identifier of this database client as an unsigned 32 bit integer.</param> /// <param name="pManager">The instance of the DatabaseManager that manages the database proxy of this database client.</param> public DatabaseClient(uint Handle, DatabaseManager pManager) { if (pManager == null) throw new ArgumentNullException("pManager"); mHandle = Handle; mManager = pManager; mConnection = new MySqlConnection(mManager.CreateConnectionString()); mCommand = mConnection.CreateCommand(); UpdateLastActivity(); }
/// <summary> /// Closes the database connection (if open) and disposes all resources. /// </summary> public void Destroy() { Disconnect(); mConnection.Dispose(); mConnection = null; mCommand.Dispose(); mCommand = null; mManager = null; }
public bool LoadBySsoTicket(DatabaseManager database, string sTicket) { DataRow result = null; using (DatabaseClient dbClient = database.GetClient()) { dbClient.AddParamWithValue("@ticket", sTicket); result = dbClient.ReadDataRow("SELECT * FROM users WHERE ssoticket = @ticket;"); if (result != null) { //dbClient.ExecuteQuery("UPDATE users SET ssoticket = NULL WHERE ssoticket = @ticket LIMIT 1;"); } } return CheckoutUserParams(ref result); }
public bool LoadByUsername(DatabaseManager database, string sUsername) { DataRow result = null; using (DatabaseClient dbClient = database.GetClient()) { dbClient.AddParamWithValue("@username", sUsername); result = dbClient.ReadDataRow("SELECT * FROM users WHERE username = @username LIMIT 1;"); } return CheckoutUserParams(ref result); }
public bool LoadByID(DatabaseManager database, uint ID) { DataRow result = null; using (DatabaseClient dbClient = database.GetClient()) { dbClient.AddParamWithValue("@id", ID); result = dbClient.ReadDataRow("SELECT * FROM users WHERE id = @id LIMIT 1;"); } return CheckoutUserParams(ref result); }
public void INSERT(DatabaseManager database) { }
public void DELETE(DatabaseManager database) { }
/// <summary> /// Boots the emulator. /// </summary> private static void Boot() { ThreadPool.SetMaxThreads(300, 400); DateTime _START = DateTime.Now; //Out.WriteLine("Starting up Holograph Emulator for " + Environment.UserName + "..."); string sqlConfigLocation = IO.workingDirectory + @"\bin\mysql.ini"; if (System.IO.File.Exists(sqlConfigLocation) == false) { Out.WriteError("mysql.ini not found at " + sqlConfigLocation); Shutdown(); return; } //Out.WriteLine("mysql.ini found at " + sqlConfigLocation); Out.WriteBlank(); dbHost = IO.readINI("mysql", "host", sqlConfigLocation); dbPort = uint.Parse(IO.readINI("mysql", "port", sqlConfigLocation)); dbUsername = IO.readINI("mysql", "username", sqlConfigLocation); dbPassword = IO.readINI("mysql", "password", sqlConfigLocation); dbName = IO.readINI("mysql", "database", sqlConfigLocation); habboVersion = "r26"; dbMaxConnections = uint.Parse(IO.readINI("mysql", "clientamount", sqlConfigLocation)); Out.WriteBlank(); dbManager = new DatabaseManager(dbHost, dbPort, dbUsername, dbPassword, dbName, 1, 100); dbManager.SetClientAmount(dbMaxConnections); dbManager.StartMonitor(); int gamePort; int gameMaxConnections; int musPort; int musMaxConnections; string musHost; try { gamePort = int.Parse(Config.getTableEntry("server_game_port")); gameMaxConnections = int.Parse(Config.getTableEntry("server_game_maxconnections")); musPort = int.Parse(Config.getTableEntry("server_mus_port")); musMaxConnections = int.Parse(Config.getTableEntry("server_mus_maxconnections")); musHost = Config.getTableEntry("server_mus_host"); } catch { Out.WriteError("system_config table contains invalid values for socket server configuration!"); Shutdown(); return; } string langExt = Config.getTableEntry("lang"); if (langExt == "") { Out.WriteError("No valid language extension [field: lang] was set in the system_config table!"); Shutdown(); return; } stringManager.Init(langExt, false); Out.WriteBlank(); stringManager.initFilter(false); Out.WriteBlank(); catalogueManager.Init(false); Out.WriteBlank(); navigatorManager.Init(); Out.WriteBlank(); //buddyManager.init(); Out.WriteBlank(); recyclerManager.Init(false); Out.WriteBlank(); rankManager.Init(false); Out.WriteBlank(); Config.Init(false); Out.WriteBlank(); userManager.Init(); eventManager.Init(); if (gameSocketServer.Init(gamePort, gameMaxConnections) == false) { Shutdown(); return; } Out.WriteBlank(); if (musSocketServer.Init(musPort, musHost) == false) { Shutdown(); return; } Out.WriteBlank(); resetDynamics(); printDatabaseStats(); Out.WriteBlank(); DateTime _STOP = DateTime.Now; TimeSpan _TST = _STOP - _START; Out.WriteLine("Total DB Pooling >> MySQL Net Connector 5.2.5 >> Hotel Emulator - Startup Time: " + _TST.TotalMilliseconds.ToString() + "."); GC.Collect(); //Out.WriteLine("Holo TDbP EXTREME edition Hotel Emulator - Ready!"); Out.WriteBlank(); string date = DateAndTime.Now.ToString(); //Out.WritePlain(date); Out.minimumImportance = Out.logFlags.MehAction; // All logs serverMonitor.Priority = ThreadPriority.Lowest; serverMonitor.Start(); }
/// <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"); } 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); } }