/// <summary> /// Invokes the command. /// </summary> /// <param name="inputData">The input data.</param> internal static void InvokeCommand(string inputData) { if (string.IsNullOrEmpty(inputData) && YupiWriterManager.DisabledState) { return; } try { if (inputData == null) { return; } string firstArgument = inputData, secondArgument = string.Empty; if (inputData.Contains(" ")) { string[] strArguments = inputData.Split(' '); firstArgument = strArguments[0]; secondArgument = strArguments[1]; } switch (firstArgument) { case "shutdown": YupiLogManager.LogMessage($"Server Shutdowning at {DateTime.Now}."); YupiWriterManager.DisablePrimaryWriting(true); YupiWriterManager.WriteLine("Shutdown Initalized", "Yupi.Life", ConsoleColor.DarkYellow); Yupi.PerformShutDown(); Console.WriteLine(); break; case "restart": YupiLogManager.LogMessage($"Server Restarting at {DateTime.Now}."); YupiWriterManager.DisablePrimaryWriting(true); YupiWriterManager.WriteLine("Restart Initialized", "Yupi.Life", ConsoleColor.DarkYellow); Yupi.PerformRestart(); Console.WriteLine(); break; case "reload": switch (secondArgument) { case "database": Console.WriteLine("Database destroyed"); Console.WriteLine(); break; case "packets": LibraryParser.ReloadDictionarys(); Console.WriteLine("> Packets Reloaded Suceffuly..."); Console.WriteLine(); break; case "catalogue": FurnitureDataManager.SetCache(); using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor()) GetGame().GetCatalogManager().Init(adapter); FurnitureDataManager.Clear(); GetGame() .GetClientManager() .QueueBroadcaseMessage( new ServerMessage(LibraryParser.OutgoingRequest("PublishShopMessageComposer"))); Console.WriteLine("Catalogue was re-loaded."); Console.WriteLine(); break; case "modeldata": using (IQueryAdapter adapter2 = Yupi.GetDatabaseManager().GetQueryReactor()) GetGame().GetRoomManager().LoadModels(adapter2); Console.WriteLine("Room models were re-loaded."); Console.WriteLine(); break; case "bans": using (IQueryAdapter adapter3 = Yupi.GetDatabaseManager().GetQueryReactor()) GetGame().GetBanManager().LoadBans(adapter3); Console.WriteLine("Bans were re-loaded"); Console.WriteLine(); break; case "filter": UserChatInputFilter.Reload(); BlackWordsManager.Reload(); break; default: UnknownCommand(inputData); Console.WriteLine(); break; } break; case "clear": Console.Clear(); break; case "status": TimeSpan uptime = DateTime.Now - Yupi.YupiServerStartDateTime; Console.WriteLine("Server status:"); Console.WriteLine(); Console.WriteLine("Uptime:"); Console.WriteLine("\tDays: {0}", uptime.Days); Console.WriteLine("\tHours: {0}", uptime.Hours); Console.WriteLine("\tMinutes: {0}", uptime.Minutes); Console.WriteLine(); Console.WriteLine("Stats:"); Console.WriteLine("\tAccepted Connections: {0}", Yupi.GetConnectionManager().Manager.AcceptedConnections); Console.WriteLine("\tActive Threads: {0}", Process.GetCurrentProcess().Threads.Count); Console.WriteLine(); Console.WriteLine(); break; case "gcinfo": { Console.WriteLine("Mode: " + GCSettings.LatencyMode); Console.WriteLine("Is server GC: " + GCSettings.IsServerGC); break; } case "memstat": { Console.WriteLine("GC status:"); Console.WriteLine("\tGeneration supported: " + GC.MaxGeneration); Console.WriteLine("\tLatency mode: " + GCSettings.LatencyMode); Console.WriteLine("\tIs server GC: " + GCSettings.IsServerGC); Console.WriteLine(); break; } case "memory": { GC.Collect(); Console.WriteLine("Memory flushed"); break; } case "help": Console.WriteLine("shutdown"); Console.WriteLine("clear"); Console.WriteLine("memory"); Console.WriteLine("status"); Console.WriteLine("restart"); Console.WriteLine("memstat"); Console.WriteLine("reload catalogue"); Console.WriteLine("reload modeldata"); Console.WriteLine("reload bans"); Console.WriteLine("reload packets"); Console.WriteLine("reload filter"); Console.WriteLine("reload packets"); Console.WriteLine("reload database"); Console.WriteLine(); break; default: UnknownCommand(inputData); break; } } catch (Exception) { // ignored } }
/// <summary> /// Invokes the command. /// </summary> /// <param name="inputData">The input data.</param> internal static void InvokeCommand(string inputData) { if (string.IsNullOrEmpty(inputData) && ServerLogManager.DisabledState) { return; } Console.WriteLine(); try { if (inputData == null) { return; } string[] strArray = inputData.Split(' '); switch (strArray[0]) { case "shutdown": case "close": ServerLogManager.DisablePrimaryWriting(true); Writer.WriteLine("Shutdown Initalized", "Yupi.Life", ConsoleColor.DarkYellow); Yupi.PerformShutDown(false); Console.WriteLine(); break; case "restart": ServerLogManager.LogMessage($"Server Restarting at {DateTime.Now}"); ServerLogManager.DisablePrimaryWriting(true); Writer.WriteLine("Restart Initialized", "Yupi.Life", ConsoleColor.DarkYellow); Yupi.PerformShutDown(true); Console.WriteLine(); break; case "flush": case "reload": if (strArray.Length >= 2) { break; } Console.WriteLine("Please specify parameter. Type 'help' to know more about Console Commands"); Console.WriteLine(); break; case "alert": { string str = inputData.Substring(6); ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("BroadcastNotifMessageComposer")); message.AppendString(str); message.AppendString(string.Empty); GetGame().GetClientManager().QueueBroadcaseMessage(message); Console.WriteLine("[{0}] was sent!", str); return; } case "clear": Console.Clear(); break; case "status": TimeSpan uptime = DateTime.Now - Yupi.ServerStarted; Console.WriteLine("Server status:"); Console.WriteLine(); Console.WriteLine("Uptime:"); Console.WriteLine("\tDays: {0}", uptime.Days); Console.WriteLine("\tHours: {0}", uptime.Hours); Console.WriteLine("\tMinutes: {0}", uptime.Minutes); Console.WriteLine(); Console.WriteLine("Stats:"); Console.WriteLine("\tAccepted Connections: {0}", Yupi.GetConnectionManager().Manager.AcceptedConnections); Console.WriteLine("\tActive Threads: {0}", Process.GetCurrentProcess().Threads.Count); Console.WriteLine(); Console.WriteLine(); break; case "gcinfo": { Console.WriteLine("Mode: " + GCSettings.LatencyMode); Console.WriteLine("Is server GC: " + GCSettings.IsServerGC); break; } case "memstat": { Console.WriteLine("GC status:"); Console.WriteLine("\tGeneration supported: " + GC.MaxGeneration); Console.WriteLine("\tLatency mode: " + GCSettings.LatencyMode); Console.WriteLine("\tIs server GC: " + GCSettings.IsServerGC); Console.WriteLine(); break; } case "memory": { GC.Collect(); Console.WriteLine("Memory flushed"); break; } case "help": Console.WriteLine("shutdown/close - for safe shutting down Yupi"); Console.WriteLine("clear - Clear all text"); Console.WriteLine("memory - Call gargabe collector"); Console.WriteLine("alert (msg) - send alert to Every1!"); Console.WriteLine("flush/reload"); Console.WriteLine(" - catalog"); Console.WriteLine(" - modeldata"); Console.WriteLine(" - bans"); Console.WriteLine(" - packets (reload packets ids)"); Console.WriteLine(" - filter"); Console.WriteLine(); break; default: UnknownCommand(inputData); break; } switch (strArray[1]) { case "database": Console.WriteLine("Database destroyed"); Console.WriteLine(); break; case "packets": LibraryParser.ReloadDictionarys(); Console.WriteLine("> Packets Reloaded Suceffuly..."); Console.WriteLine(); break; case "catalog": case "shop": case "catalogus": FurnitureDataManager.SetCache(); using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor()) GetGame().GetCatalog().Initialize(adapter); FurnitureDataManager.Clear(); GetGame() .GetClientManager() .QueueBroadcaseMessage( new ServerMessage(LibraryParser.OutgoingRequest("PublishShopMessageComposer"))); Console.WriteLine("Catalogue was re-loaded."); Console.WriteLine(); break; case "modeldata": using (IQueryAdapter adapter2 = Yupi.GetDatabaseManager().GetQueryReactor()) GetGame().GetRoomManager().LoadModels(adapter2); Console.WriteLine("Room models were re-loaded."); Console.WriteLine(); break; case "bans": using (IQueryAdapter adapter3 = Yupi.GetDatabaseManager().GetQueryReactor()) GetGame().GetBanManager().LoadBans(adapter3); Console.WriteLine("Bans were re-loaded"); Console.WriteLine(); break; case "filter": UserChatInputFilter.Reload(); BlackWordsManager.Reload(); break; default: UnknownCommand(inputData); Console.WriteLine(); break; } } catch (Exception) { // ignored } }