コード例 #1
0
ファイル: Program.cs プロジェクト: skadiD/UCS-GUI
        private static void InitUCS()
        {
            new ResourcesManager();
            new ObjectManager();
            new Gateway().Start();
            new ApiManager();
            if (!Directory.Exists("logs"))
            {
                Console.WriteLine("Folder \"logs/\" does not exist. Let me create one..");
                Directory.CreateDirectory("logs");
            }

            if (Convert.ToBoolean(Utils.parseConfigString("apiManagerPro")))
            {
                if (ConfigurationManager.AppSettings["ApiKey"] == null)
                {
                    var random = new Random();
                    var chars  = "A1b5B6b7C1c5D3";
                    var ch     = Convert.ToString(chars[random.Next(chars.Length)]);
                    ConfigurationManager.AppSettings.Set("ApiKey", ch);
                }
                var ws = new ApiManagerPro(ApiManagerPro.SendResponse,
                                           "http://+:" + Utils.parseConfigInt("proDebugPort") + "/" + Utils.parseConfigString("ApiKey") + "/");
                ws.Run();
            }

            Debugger.SetLogLevel(Utils.parseConfigInt("loggingLevel"));
            Logger.SetLogLevel(Utils.parseConfigInt("loggingLevel"));

            InitProgramThreads();

            if (Utils.parseConfigInt("loggingLevel") >= 5)
            {
                Debugger.WriteLine("\t", null, 5);
                Debugger.WriteLine("Played ID's:", null, 5, ConsoleColor.Blue);
                foreach (var id in ResourcesManager.GetAllPlayerIds())
                {
                    Debugger.WriteLine("\t" + id, null, 5, ConsoleColor.Blue);
                }
                Debugger.WriteLine("\t", null, 5);
            }
            Console.WriteLine("Server started on port " + port + ". Let's play Clash of Clans!");

            if (Convert.ToBoolean(Utils.parseConfigString("consoleCommand")))
            {
                new Menu();
            }
            else
            {
                //Application.Run(new UCSManager());
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: skadiD/UCS-GUI
        private static void InitProgramThreads()
        {
            Debugger.WriteLine("\t", null, 5);
            Debugger.WriteLine("Server Thread's:", null, 5, ConsoleColor.Blue);
            var programThreads = new List <Thread>();

            for (var i = 0; i < int.Parse(ConfigurationManager.AppSettings["programThreadCount"]); i++)
            {
                var pt = new ProgramThread();
                programThreads.Add(new Thread(pt.Start));
                programThreads[i].Start();
                Debugger.WriteLine("\tServer Running On Thread " + i, null, 5, ConsoleColor.Blue);
            }
            Console.ResetColor();
        }