Exemple #1
0
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .UseSystemd()
        .ConfigureServices((hostContext, services) =>
        {
            var commandProcessorSettings = new CommandProcessorSettings()
            {
                Url = hostContext.Configuration["AzureFunction:Url"]
            };
            var steamCommandProcessorSettings = new SteamCommandProcessorSettings()
            {
                SteamWebApiKey = hostContext.Configuration["Secrets:SteamWebApiKey"]
            };
            var azureFunctionClient = new AzureFunctionClient(commandProcessorSettings, steamCommandProcessorSettings);

            services.AddSingleton <IIrcClient>(x =>
            {
                var ircUrl           = hostContext.Configuration["Secrets:TwitchIrcUrl"];
                var port             = int.Parse(hostContext.Configuration["Secrets:TwitchIrcPort"]);
                var botUsername      = hostContext.Configuration["Secrets:BotUsername"];
                var twitchOAuthToken = hostContext.Configuration["Secrets:TwitchOAuthToken"];
                var channelName      = hostContext.Configuration["Secrets:ChannelName"];
                var logger           = x.GetService <ILogger <IrcClient> >();

                return(new IrcClient(ircUrl, port, botUsername, twitchOAuthToken, channelName, logger));
            });
            services.AddSingleton <IPinger>(x =>
            {
                return(new Pinger(x.GetService <IIrcClient>(), x.GetService <ILogger <Pinger> >()));
            });
            services.AddSingleton <ICommandProcessorSettings>(commandProcessorSettings);
            services.AddSingleton <ISteamCommandProcessorSettings>(steamCommandProcessorSettings);
            services.AddSingleton <IAzureFunctionClient>(azureFunctionClient);
            services.AddHostedService <TwitchBotWorker>();
        });
        // Use this for initialization
        void Start()
        {
            if (canvas == null)
            {
                Debug.unityLogger.LogError(kTAG, "Attach 'canvas' property to root Canvas game object in hierarchy.");
                return;
            }

            if (messageViewPrefab == null)
            {
                Debug.unityLogger.LogError(kTAG, "To use the message view the associated prefabs must be attached.");
                return;
            }

            client         = AzureFunctionClient.Create(account);
            messageService = new AzureFunction(messageFunction, client, key);
        }
Exemple #3
0
        // Use this for initialization
        void Start()
        {
            if (canvas == null)
            {
                Debug.unityLogger.LogError(kTAG, "Attach 'canvas' property to root Canvas game object in hierarchy.");
                return;
            }

            if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(leaderboardKey) || string.IsNullOrEmpty(scoreKey))
            {
                Debug.unityLogger.LogError(kTAG, "Azure Function account and key required.");
                return;
            }

            if (tableViewPrefab == null || tableViewCellPrefab == null)
            {
                Debug.unityLogger.LogError(kTAG, "To use the table view the associated prefabs must be attached.");
                return;
            }

            client             = AzureFunctionClient.Create(account);
            leaderboardService = new AzureFunction(leaderboardFunction, client, leaderboardKey);
            scoreService       = new AzureFunction(scoreFunction, client, scoreKey);
        }