public static void Destroy(bool close = true) { if (Server.ServerShutdown) { return; } Server.ServerShutdown = true; if (Server.PolicyListener != null) { Server.PolicyListener.Stop(); } Server.PolicyListener = null; if (Server.SocketManager != null) { foreach (GameConnection connection in Server.GetSocketManager().GetClients()) { try { connection.SendPacket(new MaintenanceOutgoingPacket(true)); } catch { } } Server.SocketManager.Stop(); } Server.SocketManager = null; if (close) { Environment.Exit(0); } }
public void Init() { Logging.WriteLine(@".---. . .---. . .-. ", ConsoleColor.Yellow); Logging.WriteLine(@"| _|_ | | ( ) ", ConsoleColor.Yellow); Logging.WriteLine(@"|--- .-. .--. | |--- .-. .-. .-.| `-. .-. .--.. ._ .-. .--.", ConsoleColor.Yellow); Logging.WriteLine(@"| ( ) `--. | | ( )( )( | ( )(.-' | \ / (.-' | ", ConsoleColor.Yellow); Logging.WriteLine(@"' `-'`-`--' `-'' `-' `-' `-'`- `-' `--'' `' `--'' ", ConsoleColor.Yellow); Logging.WriteLine(Server.Version, ConsoleColor.Yellow); Logging.WriteLine("Made by Jonny", ConsoleColor.Yellow); Logging.WriteBlank(); try { Server.ServerStarted = Stopwatch.StartNew(); Server.ConfigurationData = new ConfigurationData("config.conf"); Server.Game = new Game(); Server.APIListener = new APIListener(Server.Config["game.tcp.ip"], int.Parse(Server.Config["game.api.port"])); Server.APIListener.Start(); Server.PolicyListener = new PolicyListener(Server.Config["game.tcp.ip"], int.Parse(Server.Config["game.policy.port"])); Server.PolicyListener.Start(); Server.SocketManager = new SocketManager(Server.Config["game.tcp.ip"], int.Parse(Server.Config["game.tcp.port"])); Server.SocketManager.Start(); TimeSpan bootTime = Server.Uptime; Logging.WriteLine("READY! (" + bootTime.Seconds + " s, " + bootTime.Milliseconds + " ms)", ConsoleColor.Green); } catch (Exception ex) { Logging.WriteLine("FAILED TO BOOT! ", ConsoleColor.Red); Server.ExceptionShutdown(ex); } }