/// <summary> /// Program entry. /// </summary> /// <param name="args">Process arguments.</param> public static void Main(string[] args) { Console.Title = "ProjectX V3 - Game Server"; try { config = new XmlConfig(); config.LoadConfig(Database.ServerDatabase.DatabaseLocation + "\\Config.xml"); } catch (Exception e) { Console.WriteLine("Could not load the config."); Console.WriteLine("Error:"); Console.WriteLine(e); Console.ReadLine(); return; } if (!Database.ServerDatabase.Load()) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Could not load the database."); Console.ReadLine(); return; } Threads.GlobalThreads.Start(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Starting the server..."); try { Network.GameAuth.Start(); SocketEvents sockEvents = new SocketEvents(); sockEvents.OnConnection = new ConnectionEvent(Network.NetworkConnections.Handle_Connection); sockEvents.OnDisconnection = new ConnectionEvent(Network.NetworkConnections.Handle_Disconnection); sockEvents.OnReceive = new BufferEvent(Network.NetworkConnections.Handle_Receive); BeginServer(sockEvents, config.ReadInt32("GamePort")); ProjectX_V3_Lib.Native.Kernel32.SetConsoleCtrlHandler( new ProjectX_V3_Lib.Native.Kernel32.ConsoleEventHandler(Console_CloseEvent), true); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("The server is open..."); Console.ResetColor(); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Could not open the server..."); Console.WriteLine(e.ToString()); Console.ReadLine(); return; } while (true) HandleCmd(Console.ReadLine()); }
/// <summary> /// Program Entry. /// </summary> /// <param name="args">Process arguments.</param> public static void Main(string[] args) { Console.Title = "ProjectX V3 - Auth Server"; try { config = new XmlConfig(); config.LoadConfig(Database.ServerDatabase.DatabaseLocation + "\\Config.xml"); } catch (Exception e) { Console.WriteLine("Could not load the config."); Console.WriteLine("Error:"); Console.WriteLine(e); Console.ReadLine(); return; } Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Starting the server..."); try { SocketEvents sockEvents = new SocketEvents(); sockEvents.OnConnection = new ConnectionEvent(Network.NetworkConnections.Handle_Connection); sockEvents.OnReceive = new BufferEvent(Network.NetworkConnections.Handle_Receive); int[] ports; config.ReadString("Ports").Split(',').ConverToInt32(out ports); foreach (int port in ports) BeginServer(sockEvents, port); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("The server is open..."); Console.ResetColor(); while (true) Console.ReadLine(); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Could not open the server..."); Console.WriteLine(e.ToString()); Console.ReadLine(); } }