Exemplo n.º 1
0
        internal static async Task Init()
        {
            if (!PluginsCore.InitPlugins())
            {
                await Task.Delay(10000).ConfigureAwait(false);
            }

            WebBrowser = new WebBrowser(ArchiLogger, GlobalConfig.WebProxy, true);

            await UpdateAndRestart().ConfigureAwait(false);

            await PluginsCore.OnASFInitModules(GlobalConfig.AdditionalProperties).ConfigureAwait(false);

            StringComparer botsComparer = await PluginsCore.GetBotsComparer().ConfigureAwait(false);

            InitBotsComparer(botsComparer);

            if (!GlobalConfig.Headless && !Console.IsInputRedirected)
            {
                Logging.StartInteractiveConsole();
            }

            if (GlobalConfig.IPC)
            {
                await ArchiKestrel.Start().ConfigureAwait(false);
            }

            await RegisterBots().ConfigureAwait(false);

            InitEvents();
        }
Exemplo n.º 2
0
        private static async Task RefreshChanges()
        {
            if (!await RefreshSemaphore.WaitAsync(0).ConfigureAwait(false))
            {
                return;
            }

            try {
                Bot refreshBot = null;
                SteamApps.PICSChangesCallback picsChanges = null;

                for (byte i = 0; (i < WebBrowser.MaxTries) && (picsChanges == null); i++)
                {
                    refreshBot = Bot.Bots.Values.FirstOrDefault(bot => bot.IsConnectedAndLoggedOn);

                    if (refreshBot == null)
                    {
                        return;
                    }

                    try {
                        picsChanges = await refreshBot.SteamApps.PICSGetChangesSince(LastChangeNumber, true, true).ToLongRunningTask().ConfigureAwait(false);
                    } catch (Exception e) {
                        refreshBot.ArchiLogger.LogGenericWarningException(e);
                    }
                }

                if ((refreshBot == null) || (picsChanges == null))
                {
                    ASF.ArchiLogger.LogGenericWarning(Strings.WarningFailed);

                    return;
                }

                if (picsChanges.CurrentChangeNumber == picsChanges.LastChangeNumber)
                {
                    return;
                }

                LastChangeNumber = picsChanges.CurrentChangeNumber;

                if (picsChanges.RequiresFullAppUpdate || picsChanges.RequiresFullPackageUpdate || ((picsChanges.AppChanges.Count == 0) && (picsChanges.PackageChanges.Count == 0)))
                {
                    await PluginsCore.OnPICSChangesRestart(picsChanges.CurrentChangeNumber).ConfigureAwait(false);

                    return;
                }

                if (picsChanges.PackageChanges.Count > 0)
                {
                    await ASF.GlobalDatabase.RefreshPackages(refreshBot, picsChanges.PackageChanges.ToDictionary(package => package.Key, package => package.Value.ChangeNumber)).ConfigureAwait(false);
                }

                await PluginsCore.OnPICSChanges(picsChanges.CurrentChangeNumber, picsChanges.AppChanges, picsChanges.PackageChanges).ConfigureAwait(false);
            } finally {
                RefreshSemaphore.Release();
            }
        }