示例#1
0
        public static void Main()
        {
            var    version = Assembly.GetExecutingAssembly().GetName().Version;
            string date    = new DateTime(2000, 01, 01).AddDays(version.Build).AddSeconds(version.Revision * 2).ToUniversalTime().ToString();

            Log.WriteInfo("Main", "Built on {0} UTC", date);

            try
            {
                Settings.Load();
            }
            catch (Exception e)
            {
                Log.WriteError("Settings", "{0}", e.Message);

                return;
            }

            if (Settings.Current.SteamKitDebug)
            {
                DebugLog.AddListener(new Log.SteamKitLogger());
                DebugLog.Enabled = true;
            }

            AppDomain.CurrentDomain.UnhandledException += OnSillyCrashHandler;

            Console.CancelKeyPress += delegate
            {
                Cleanup();
            };

            var thread = new Thread(new ThreadStart(Steam.Instance.Init));

            thread.Name = "Steam";
            thread.Start();

            // We don't need GC idlers in full run
            if (Settings.IsFullRun)
            {
                return;
            }

            foreach (var appID in Settings.Current.GameCoordinatorIdlers)
            {
                var instance = new GCIdler(appID);

                thread      = new Thread(new ThreadStart(instance.Run));
                thread.Name = string.Format("GC Idler {0}", appID);
                thread.Start();

                GCIdlers.Add(instance);
            }

            if (Settings.CanConnectToIRC())
            {
                SteamProxy.Instance.ReloadImportant();

                IRC.Instance.Init();
            }
        }
        public static void Init()
        {
            var thread = new Thread(new ThreadStart(Steam.Instance.Tick));
            thread.Name = "Steam";
            thread.Start();

            Threads.Add(thread);

            if (Settings.IsFullRun)
            {
                return;
            }

            ReloadImportant();

            var commandHandler = new CommandHandler();

            Steam.Instance.RegisterCommandHandlers(commandHandler);

            if (Settings.Current.IRC.Enabled)
            {
                thread = new Thread(new ThreadStart(IRC.Instance.Connect));
                thread.Name = "IRC";
                thread.Start();

                Threads.Add(thread);

                IRC.Instance.RegisterCommandHandlers(commandHandler);
            }

            foreach (var appID in Settings.Current.GameCoordinatorIdlers)
            {
                var instance = new GCIdler(appID);

                thread = new Thread(new ThreadStart(instance.Run));
                thread.IsBackground = true;
                thread.Name = string.Format("GC Idler {0}", appID);
                thread.Start();

                GCIdlers.Add(instance);
                Threads.Add(thread);
            }
        }
示例#3
0
        public static void Main()
        {
            var version = Assembly.GetExecutingAssembly().GetName().Version;
            string date = new DateTime(2000, 01, 01).AddDays(version.Build).AddSeconds(version.Revision * 2).ToUniversalTime().ToString();

            Log.WriteInfo("Main", "Built on {0} UTC", date);

            try
            {
                Settings.Load();
            }
            catch (Exception e)
            {
                Log.WriteError("Settings", "{0}", e.Message);

                return;
            }

            if (Settings.Current.SteamKitDebug)
            {
                DebugLog.AddListener(new Log.SteamKitLogger());
                DebugLog.Enabled = true;
            }

            Console.CancelKeyPress += delegate
            {
                Log.WriteInfo("Main", "Exiting...");

                foreach (var idler in GCIdlers)
                {
                    try
                    {
                        idler.IsRunning = false;
                        idler.Client.Disconnect();
                    }
                    catch { }
                }

                Steam.Instance.IsRunning = false;

                try { Steam.Instance.Timer.Stop();                       } catch { }
                try { DepotProcessor.ThreadPool.Shutdown(true, 1000);    } catch { }
                try { Steam.Instance.SecondaryPool.Shutdown(true, 1000); } catch { }
                try { Steam.Instance.ProcessorPool.Shutdown(true, 1000); } catch { }
                try { Steam.Instance.Client.Disconnect();                } catch { }

                if (Settings.Current.IRC.Enabled)
                {
                    IRC.Instance.Kill();
                }

                DbWorker.ExecuteNonQuery("TRUNCATE TABLE `GC`");
            };

            Thread thread = new Thread(new ThreadStart(Steam.Instance.Init));
            thread.Name = "Steam";
            thread.Start();

            if (Settings.Current.FullRun > 0)
            {
                Settings.Current.IRC.Enabled = false;

                return;
            }

            foreach (var idler in Settings.Current.GameCoordinatorIdlers)
            {
                if (string.IsNullOrWhiteSpace(idler.Username) || string.IsNullOrWhiteSpace(idler.Password) || idler.AppID <= 0)
                {
                    Log.WriteWarn("Settings", "Invalid GC coordinator settings");
                    continue;
                }

                Log.WriteInfo("Main", "Starting GC idler for app {0}", idler.AppID);

                var instance = new GCIdler(idler.AppID, idler.Username, idler.Password);

                thread = new Thread(new ThreadStart(instance.Run));
                thread.Name = "Steam";
                thread.Start();

                GCIdlers.Add(instance);
            }

            if (Settings.CanConnectToIRC())
            {
                SteamProxy.Instance.ReloadImportant();

                IRC.Instance.Init();
            }
        }
示例#4
0
        public static void Main()
        {
            var version = Assembly.GetExecutingAssembly().GetName().Version;
            string date = new DateTime(2000, 01, 01).AddDays(version.Build).AddSeconds(version.Revision * 2).ToUniversalTime().ToString();

            Log.WriteInfo("Main", "Built on {0} UTC", date);

            try
            {
                Settings.Load();
            }
            catch (Exception e)
            {
                Log.WriteError("Settings", "{0}", e.Message);

                return;
            }

            if (Settings.Current.SteamKitDebug)
            {
                DebugLog.AddListener(new Log.SteamKitLogger());
                DebugLog.Enabled = true;
            }

            AppDomain.CurrentDomain.UnhandledException += OnSillyCrashHandler;

            Console.CancelKeyPress += delegate
            {
                Cleanup();
            };

            var thread = new Thread(new ThreadStart(Steam.Instance.Init));
            thread.Name = "Steam";
            thread.Start();

            if (Settings.Current.FullRun > 0)
            {
                Settings.Current.IRC.Enabled = false;

                return;
            }

            foreach (var idler in Settings.Current.GameCoordinatorIdlers)
            {
                if (string.IsNullOrWhiteSpace(idler.Username) || string.IsNullOrWhiteSpace(idler.Password) || idler.AppID <= 0)
                {
                    Log.WriteWarn("Settings", "Invalid GC coordinator settings");
                    continue;
                }

                Log.WriteInfo("Main", "Starting GC idler for app {0}", idler.AppID);

                var instance = new GCIdler(idler.AppID, idler.Username, idler.Password);

                thread = new Thread(new ThreadStart(instance.Run));
                thread.Name = string.Format("GC Idler {0}", idler.AppID);
                thread.Start();

                GCIdlers.Add(instance);
            }

            if (Settings.CanConnectToIRC())
            {
                SteamProxy.Instance.ReloadImportant();

                IRC.Instance.Init();
            }
        }