Example #1
0
        public void WaitForCommands()
        {
            string input = null;

            this.Start();
            ServerGlobals.Init();
            while (!IsConsoleShuttingDown)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.Write("\n(Router Server) ");
                Console.ResetColor();
                input = Console.ReadLine();
                string[] args = input.Split(' ');



                switch (args[0].ToLower())
                {
                case "start":
                {
                    this.Start();
                }
                break;

                case "ip":
                {
                    IPAddress add = Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork);
                    Console.WriteLine(add);
                }
                break;

                case "stop":
                    ThreadMgr.Stop();
                    srv.Stop();
                    break;

                case "exit":
                    this.Stop();
                    break;

                default:
                    Console.WriteLine("No Such Command: " + input + "\r\n");
                    break;
                }
            }
        }
Example #2
0
 public void Start()
 {
     // if (cmd.Length == 3)
     // {
     srv.TcpIP     = IPAddress.Any;
     srv.TcpPort   = 8001;
     srv.EnableTCP = true;
     ServerGlobals.Init();
     ThreadMgr.Start();
     srv.Start();
     // Turn on and test our mysql
     try
     {
         bool mysql = MySqlManager.TestConnection;
         Console.WriteLine("MySql Initialize {0}", mysql ? "Successful" : "Unsuccessful");
     }
     catch (Exception ex)
     {
         Console.WriteLine("Unable to continue, error is {0}\nPress any key to close!", ex.Message);
         Console.Read();
         this.IsConsoleShuttingDown = true;
     }
 }