public static bool TwitchWhoIsLiveManager_onGameLiveStreamRequestFinished_Prefix(HTTPResponse response, ref List <TwitchStreamInfo> ____streamInfos, ref bool ____hasEverRetirevedLiveUsers) { if (response == null || !response.IsSuccess) { return(false); } try { ____streamInfos = new List <TwitchStreamInfo>(); foreach (JToken jtoken in JsonConvert.DeserializeObject <JContainer>(response.DataAsText).First.First.Children()) { TwitchStreamInfo twitchStreamInfo = jtoken.ToObject <TwitchStreamInfo>(); ____streamInfos.Add(twitchStreamInfo); } ____hasEverRetirevedLiveUsers = true; GlobalEventManager.Instance.Dispatch(GlobalEvents.TwitchLiveStreamsRefreshed); } catch (Exception exception) { ErrorManager.Instance.LogExceptionWithoutPausingGame(exception, "onGameLiveStreamRequestFinished Error"); } return(false); }
private void InitializeStreamInfo() { streamInfo = MyTwitchChannelInfo.Instance.StreamInfo; if (streamInfo == null) { MyTwitchChannelInfo.Instance.ForceStreamInfoRefresh(); } }
public static async Task <List <UserStreams> > GetStreams() { HttpClient HTTPClient = new HttpClient(); HTTPClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {Global.TwitchOauthKey}"); HTTPClient.DefaultRequestHeaders.Add("Client-Id", $"{Global.TwitchClientId}"); HttpResponseMessage HTTPResponse = await HTTPClient.GetAsync($"https://api.twitch.tv/helix/streams"); string resp = await HTTPResponse.Content.ReadAsStringAsync(); TwitchStreamInfo myDeserializedClass = JsonConvert.DeserializeObject <TwitchStreamInfo>(resp); return(myDeserializedClass.data); }
private void TimerTick(object sender, EventArgs e) { ChattersDowload(out Chatters allChatters); var tsi = new TwitchStreamInfo(); TwitchStreamInfoLoad(ref tsi); if (tsi.Stream != null) { ViewerLabel.Content = "Viewers " + ((tsi.Stream.Viewers) ?? 1); } else { ViewerLabel.Content = "Viewers " + 0; } var props = allChatters.Chatter.GetType().GetRuntimeProperties(); ViewerList.Items.Clear(); foreach (var prop in props) { var getMethodProperty = prop.GetMethod; var chatters = (IList)getMethodProperty.Invoke(allChatters.Chatter, null); if (chatters.Count < 1) { continue; } ViewerList.Items.Add(new ListBoxItem { Content = prop.Name, FontSize = 18, Foreground = Brushes.DarkRed }); foreach (var chatter in chatters) { ViewerList.Items.Add(new ListBoxItem { Content = chatter.ToString(), Foreground = prop.Name.ToLower().ColorViewer() }); } ViewerList.Items.Add(Environment.NewLine); } irc.PingResponse(); }
private static void TwitchStreamInfoLoad(ref TwitchStreamInfo t) { var req = WebRequest.Create(new Uri($"https://api.twitch.tv/kraken/streams/{Channel}")); req.Headers.Add($"Client-ID: {TwitchClientId}"); //req.Timeout = 3000; var resp = req.GetResponse(); using (Stream s = resp.GetResponseStream()) using (StreamReader sr = new StreamReader(s)) using (JsonReader reader = new JsonTextReader(sr)) { //Clipboard.SetText(sr.ReadToEnd()); JsonSerializer serializer = new JsonSerializer(); t = serializer.Deserialize <TwitchStreamInfo>(reader); } }
private void Instance_TwitchStreamInfoChanged(object sender, TwitchStreamInfoEventArgs e) { streamInfo = e.StreamInfo; }