public UpdateFollowersTask(IHubContext <FollowersHub> hubContext, ITwitchApiClient twitchApiClient, UserAccessTokenStore userAccessTokenStore, int toId) { _hubContext = hubContext; _twitchApiClient = twitchApiClient; _userAccessTokenStore = userAccessTokenStore; _toId = toId; }
public UpdateSubsTask(IHubContext <SubsHub> hubContext, ITwitchApiClient twitchApiClient, UserAccessTokenStore userAccessTokenStore, int streamId) { _hubContext = hubContext; _twitchApiClient = twitchApiClient; _userAccessTokenStore = userAccessTokenStore; _streamId = streamId; }
public TwitchWebHookController( IHubContext <FollowersHub> followersHubContext, IHubContext <SubsHub> subsHubContext, ITwitchApiClient twitchApiClient, UserAccessTokenStore userAccessTokenStore) { _followersHubContext = followersHubContext; _subsHubContext = subsHubContext; _twitchApiClient = twitchApiClient; _userAccessTokenStore = userAccessTokenStore; }
public FollowersHub(IConfiguration configuration, ITwitchApiClient twitchApiClient, UserAccessTokenStore userAccessTokenStore) { _configuration = configuration; _twitchApiClient = twitchApiClient; _userAccessTokenStore = userAccessTokenStore; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSignalR(); services.AddControllersWithViews().AddNewtonsoftJson(); //add user access state store services.AddSingleton <UserAccessStateStore, UserAccessStateStore>(serviceProvider => { return(new UserAccessStateStore()); }); //add user access token store services.AddSingleton <UserAccessTokenStore, UserAccessTokenStore>(serviceProvider => { return(new UserAccessTokenStore()); }); //add twitch api client services.AddSingleton <ITwitchApiClient, TwitchApiClient>(serviceProvider => { IConfiguration configuration = serviceProvider.GetService <IConfiguration>(); IConfigurationSection appSettings = configuration.GetSection("AppSettings"); string clientId = appSettings["api-client-id"]; string clientSecret = appSettings["api-client-secret"]; return(new TwitchApiClient(clientId, clientSecret)); }); //add scheduled webhook subscription task for follows services.AddSingleton <IScheduledTask, WebHookSubscriptionTask>(serviceProvider => { ITwitchApiClient twitchApiClient = serviceProvider.GetService <ITwitchApiClient>(); UserAccessTokenStore userAccessTokenStore = serviceProvider.GetService <UserAccessTokenStore>(); var model = new WebHooksModel() { Callback = "http://test-env.eba-aafhtxzp.us-west-2.elasticbeanstalk.com/api/twitchwebhook/follows", Mode = "subscribe", Topic = "https://api.twitch.tv/helix/users/follows?first=1&to_id=58669321", LeaseSeconds = 864000 //max lease time }; return(new WebHookSubscriptionTask(twitchApiClient, model, userAccessTokenStore)); }); //add scheduled webhook subscription task for subs services.AddSingleton <IScheduledTask, WebHookSubscriptionTask>(serviceProvider => { ITwitchApiClient twitchApiClient = serviceProvider.GetService <ITwitchApiClient>(); UserAccessTokenStore userAccessTokenStore = serviceProvider.GetService <UserAccessTokenStore>(); var model = new WebHooksModel() { Callback = "http://test-env.eba-aafhtxzp.us-west-2.elasticbeanstalk.com/api/twitchwebhook/subs", Mode = "subscribe", Topic = "https://api.twitch.tv/helix/subscriptions/events?broadcaster_id=58669321&first=1", LeaseSeconds = 864000 //max lease time }; return(new WebHookSubscriptionTask(twitchApiClient, model, userAccessTokenStore)); }); //add scheduled followers update task services.AddSingleton <IScheduledTask, UpdateFollowersTask>(serviceProvider => { IHubContext <FollowersHub> hubContext = serviceProvider.GetService <IHubContext <FollowersHub> >(); ITwitchApiClient twitchApiClient = serviceProvider.GetService <ITwitchApiClient>(); UserAccessTokenStore userAccessTokenStore = serviceProvider.GetService <UserAccessTokenStore>(); IConfiguration configuration = serviceProvider.GetService <IConfiguration>(); IConfigurationSection appSettings = configuration.GetSection("AppSettings"); return(new UpdateFollowersTask(hubContext, twitchApiClient, userAccessTokenStore, int.Parse(appSettings["stream-id"]))); }); //add scheduled subs update task services.AddSingleton <IScheduledTask, UpdateSubsTask>(serviceProvider => { ITwitchApiClient twitchApiClient = serviceProvider.GetService <ITwitchApiClient>(); IHubContext <SubsHub> hubContext = serviceProvider.GetService <IHubContext <SubsHub> >(); UserAccessTokenStore userAccessTokenStore = serviceProvider.GetService <UserAccessTokenStore>(); IConfiguration configuration = serviceProvider.GetService <IConfiguration>(); IConfigurationSection appSettings = configuration.GetSection("AppSettings"); return(new UpdateSubsTask(hubContext, twitchApiClient, userAccessTokenStore, int.Parse(appSettings["stream-id"]))); }); //add scheduled task - refresh user access token services.AddSingleton <IScheduledTask, RefreshUserAccessTokenTask>(serviceProvider => { ITwitchApiClient twitchApiClient = serviceProvider.GetService <ITwitchApiClient>(); UserAccessTokenStore userAccessTokenStore = serviceProvider.GetService <UserAccessTokenStore>(); return(new RefreshUserAccessTokenTask(twitchApiClient, userAccessTokenStore)); }); //add scheduler services.AddSingleton <IHostedService, SchedulerService>(serviceProvider => { var instance = new SchedulerService(serviceProvider.GetServices <IScheduledTask>()); instance.UnobservedTaskException += (sender, args) => { Console.WriteLine(args.Exception.Message); args.SetObserved(); }; return(instance); }); }
public SubsService(ITwitchApiClient twitchApiClient, UserAccessTokenStore userAccessTokenStore) { _twitchApiClient = twitchApiClient; _userAccessTokenStore = userAccessTokenStore; }
public RefreshUserAccessTokenTask(ITwitchApiClient twitchApiClient, UserAccessTokenStore userAccessTokenStore) { _twitchApiClient = twitchApiClient; _userAccessTokenStore = userAccessTokenStore; }
public WebHookSubscriptionTask(ITwitchApiClient twitchApiClient, WebHooksModel model, UserAccessTokenStore userAccessTokenStore) { _twitchApiClient = twitchApiClient; _model = model; _userAccessTokenStore = userAccessTokenStore; }