private async Task FetchInitialTwitchData() { Console.WriteLine("Fetching public IP address ..."); PersistantRuntimeData.Ip = await IpifyRepository.Get(); var username = ConfigurationManager.AppSettings["TwitchUsername"]; Console.WriteLine($"Fetching twitch user id for {username} ... "); // we need to fetch our user details so that we can request web // hook event data from twitch PersistantRuntimeData.Me = (await TwitchUserRepository.GetByName(username)).Users.Single(); Console.WriteLine($"Populating follower queue ..."); // now that we know our user id, we can fetch our the most recent // follower so that it shows up on initial load var followers = await TwitchFollowerRepository.Get(PersistantRuntimeData.Me.Id); if (followers.Followers.Count > 0) { var follower = followers .Followers .First(); // lets put them on the queue PersistantRuntimeData.Followers.Enqueue(new FollowerQueueData { To = follower.To, From = follower.From }); } Console.WriteLine($"Requesting twitch follower notifications ... "); // now that we have our own user data, we can request the web hook // event data var response = await TwitchWebhookRepository.Get( PersistantRuntimeData.Ip, PersistantRuntimeData.Me.Id, PersistantRuntimeData.Guid); }
async public Task <IHttpActionResult> Get() { try { // all we want to do is pop the next follower off the queue so that // the browser source can be unloaded and we won't lose track of // any followers in the process var follower = PersistantRuntimeData.Followers.Dequeue(); // now we need to out to twitch again and fetch the display name of // the person who followed var details = await TwitchUserRepository.GetById(follower.From); // we only want to respond with the user details return(Json(details.Users.Single())); } catch { return(StatusCode(HttpStatusCode.NoContent)); } }