Esempio n. 1
0
        static void Main()
        {
            Logger.Info("Process starting");

            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Logger.Fatal("Unhandled exception: " + e.ExceptionObject);
                Logger.Info("Process exiting");
            };

            ThreadPool.SetMaxThreads(10, 1);

            LoadSettings();

            SessionManager = new SessionManager();
            RoomManager = new RoomManager();
            DelayManager = new DelayManager();
            Steam = new Steam();

            _taskScheduler = new TaskScheduler();
            _taskScheduler.Add(TimeSpan.FromSeconds(0.5), () =>
            {
                SessionManager.Update();
                RoomManager.Update();
                DelayManager.Update();
                Steam.Update();
            });

            _taskScheduler.Add(TimeSpan.FromHours(1), () =>
            {
                var t = Util.GetUnixTimestamp(DateTime.UtcNow - TimeSpan.FromDays(30));
                LoginToken.RemoveOlderThan(t);
            });

            _taskScheduler.Add(TimeSpan.FromMinutes(2.5), () =>
            {
                if (Steam.Status == Steam.ConnectionStatus.Connected)
                {
                    Steam.Bot.PersonaState = EPersonaState.Online;
                }
            });

            while (true)
            {
                _taskScheduler.Run();
                Thread.Sleep(10);
            }
        }
Esempio n. 2
0
        static void Main()
        {
            Logger.Info("Process starting");

            /*DebugLog.AddListener((a, b) =>
            {
                Console.WriteLine("{0} {1} {2}", DateTime.Now, a, b);
            });

            DebugLog.Enabled = true;*/

            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Logger.Fatal("Unhandled exception: " + e.ExceptionObject);
                Logger.Info("Process exiting");
            };

            ThreadPool.SetMaxThreads(10, 1);

            LoadSettings();

            if (Settings == null)
            {
                Logger.Fatal("Failed to load settings!");
                return;
            }

            SessionManager = new SessionManager();
            RoomManager = new RoomManager();
            DelayManager = new DelayManager();
            Steam = new Steam();

            RoomManager.Update();
            SessionManager.Start();

            _taskScheduler = new TaskScheduler();
            _taskScheduler.Add(TimeSpan.FromSeconds(0.5), () =>
            {
                SessionManager.Update();
                RoomManager.Update();
                DelayManager.Update();
                Steam.Update();
            });

            _taskScheduler.Add(TimeSpan.FromHours(1), () =>
            {
                var t = Util.GetTimestamp(DateTime.UtcNow - TimeSpan.FromDays(30));
                LoginToken.RemoveOlderThan(t);
            });

            _taskScheduler.Add(TimeSpan.FromMinutes(2.5), () =>
            {
                if (Steam.Status == Steam.ConnectionStatus.Connected)
                {
                    Steam.Bot.PersonaState = EPersonaState.Online;
                }
            });

            while (true)
            {
                _taskScheduler.Run();
                Thread.Sleep(10);
            }
        }