internal static void DestroyJson() { InfoModelo dados = OtanixEnvironment.getStatusApi(); dados.hotel = 0; dados.onlines = 0; dados.loadRooms = 0; dados.uptime = "Servidor desligado"; APIexterna.enviaAlerta(dados); }
internal static void atualizaJson(TimeSpan Uptime) { try { InfoModelo dados = OtanixEnvironment.getStatusApi(); dados.hotel = 0; dados.onlines = OtanixEnvironment.GetGame().GetClientManager().clients.Count; dados.loadRooms = OtanixEnvironment.GetGame().GetRoomManager().loadedRooms.Count; dados.uptime = Uptime.Days + " dias " + Uptime.Hours + " horas " + Uptime.Minutes + " minutos"; APIexterna.enviaAlerta(dados); } finally { tempoJson = 0; } }
public static InfoModelo getStatusApi() { return(APIexterna.getStatus()); }
internal static void Initialize() { ServerStarted = DateTime.Now; //Console.ForegroundColor = ConsoleColor.DarkBlue; //Console.WriteLine("\n "); //Console.WriteLine(@" $$$$$$\ $$\ $$\ "); //Console.WriteLine(@" $$ __$$\ $$ | \__| "); //Console.WriteLine(@" $$ / $$ |$$$$$$\ $$$$$$\ $$$$$$$\ $$\ $$\ $$\ "); //Console.WriteLine(@" $$ | $$ |\_$$ _| \____$$\ $$ __$$\ $$ |\$$\ $$ | "); //Console.WriteLine(@" $$ | $$ | $$ | $$$$$$$ |$$ | $$ |$$ | \$$$$ / "); //Console.WriteLine(@" $$ | $$ | $$ |$$\ $$ __$$ |$$ | $$ |$$ | $$ $$< "); //Console.WriteLine(@" $$$$$$ | \$$$$ |\$$$$$$$ |$$ | $$ |$$ |$$ /\$$\ "); //Console.WriteLine(@" \______/ \____/ \_______|\__| \__|\__|\__/ \__| "); //Console.WriteLine("\n "); //Console.ForegroundColor = ConsoleColor.DarkGreen; //Console.WriteLine(@" © 2016 - 2017 - Todos os direitos reservados ao Thiago Araujo."); //Console.WriteLine(@" "); Console.ForegroundColor = ConsoleColor.Gray; try { #region Starting Configuration = new ConfigurationData(Path.Combine(Application.StartupPath, @"Settings/configuration.ini")); UsersCache.Initialize(); LowPriorityWorker.Init(); APIexterna.InitStatus(); LanguageLocale.Init(); ChatCommandRegister.Init(); PetLocale.Init(); #endregion #region MySQL Configuration var starts = DateTime.Now; Logging.WriteLine("[Otanix] @ Conectando na database..."); manager = new DatabaseManager(uint.Parse(GetConfig().data["db.pool.maxsize"]), int.Parse(GetConfig().data["db.pool.minsize"])); manager.setServerDetails( GetConfig().data["db.hostname"], uint.Parse(GetConfig().data["db.port"]), GetConfig().data["db.username"], GetConfig().data["db.password"], GetConfig().data["db.name"]); manager.init(); var timeUsed2 = DateTime.Now - starts; Logging.WriteLine("[Otanix] @ Conectado com sucesso na database! (" + timeUsed2.Seconds + " s, " + timeUsed2.Milliseconds + " ms)"); #endregion #region Cycles Configuration starts = DateTime.Now; StaticClientMessageHandler.Initialize(); ClientMessageFactory.Init(); var timeUsed3 = DateTime.Now - starts; Logging.WriteLine("[Otanix] @ Iniciando os ciclos! (" + timeUsed3.Seconds + " s, " + timeUsed3.Milliseconds + " ms)"); Game = new Game(); Game.ContinueLoading(); #endregion #region Connections Configuration ConnectionManager = new ConnectionHandeling(int.Parse(GetConfig().data["game.tcp.port"]), int.Parse(GetConfig().data["game.tcp.conlimit"]), int.Parse(GetConfig().data["game.tcp.conperip"]), GetConfig().data["game.tcp.enablenagles"].ToLower() == "true"); ConnectionManager.init(); ConnectionManager.Start(); Handler.Initialize(RsaKeyHolder.N, RsaKeyHolder.D, RsaKeyHolder.E); Logging.WriteLine("[Otanix] @ RSA Crypto iniciada!"); if (GetConfig().data["mus.enable"].ToLower() == "true") { MusSystem = new MusSocket(int.Parse(GetConfig().data["mus.tcp.port"])); } #endregion #region Last Process var TimeUsed = DateTime.Now - ServerStarted; Logging.WriteLine("[Otanix] @ ENVIRONMENT -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)"); Console.Title = "Otanix Emulador ~ Versão privada por Thiago Araujo para " + EmuSettings.HOTEL_LINK; if (Debugger.IsAttached) { Console.ForegroundColor = ConsoleColor.Blue; Logging.WriteLine("[Otanix] @ Alerta: Servidor está em DEBUG, console ativado!"); Console.ForegroundColor = ConsoleColor.White; } else { Logging.WriteLine("[Otanix] @ Alerta: Servidor não está em DEBUG, console desativado!"); Logging.DisablePrimaryWriting(false); } Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("[Otanix] @ Alerta: Pressione alguma tecla para ativar o console de comandos."); Console.ForegroundColor = ConsoleColor.White; #endregion } catch (KeyNotFoundException e) { Console.ForegroundColor = ConsoleColor.Red; Logging.WriteLine("Avviso: controlla il file di configurazione, alcuni valori sembrano mancare."); Logging.WriteLine("Avviso: premere un tasto qualsiasi per terminare il programma..."); Logging.WriteLine(e.ToString()); Console.ReadKey(true); Destroy(); } catch (InvalidOperationException e) { Console.ForegroundColor = ConsoleColor.Red; Logging.WriteLine("Avviso: impossibile avviare il programma, " + e.Message); Logging.WriteLine("Avviso: premere un tasto qualsiasi per terminare il programma..."); Console.ReadKey(true); Destroy(); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Avviso: errore di avvio irreversibile, " + e); Console.WriteLine("Avviso: premere un tasto qualsiasi per terminare il programma..."); Console.ReadKey(); Environment.Exit(1); } Console.ForegroundColor = ConsoleColor.White; }