private async void GetStreamInfo() { if (TwitchStreamInfoChanged != null && TwitchTokenManager.Instance.User != null && !string.IsNullOrEmpty(TwitchTokenManager.Instance.User.UserId)) { lastStreamInfo = await comm.GetMyStreamInfo(); if (lastStreamInfo != null) { if (tmrFetchStreamInfo.Interval != DEFAULT_REFRESH_MS) { ResetTimerInterval(); } lastStreamInfoRefresh = DateTime.Now; TwitchStreamInfoChanged?.Invoke(this, new TwitchStreamInfoEventArgs(lastStreamInfo)); return; } IncreaseTimerInterval(); TwitchStreamInfoChanged?.Invoke(this, new TwitchStreamInfoEventArgs(null)); } }
private async void GetStreamInfo() { if (TwitchStreamInfoChanged != null && TwitchTokenManager.Instance.User != null && !string.IsNullOrEmpty(TwitchTokenManager.Instance.User.UserId)) { string URI = String.Format(TWITCH_URI_STREAM_INFO, TwitchTokenManager.Instance.User.UserId); HttpResponseMessage response = await comm.TwitchQuery(URI, SendMethod.GET, null, null); if (response.IsSuccessStatusCode) { try { string body = await response.Content.ReadAsStringAsync(); JObject json = JObject.Parse(body); lastStreamInfo = json["stream"].ToObject <TwitchStreamInfo>(); if (tmrFetchStreamInfo.Interval != DEFAULT_REFRESH_MS) { ResetTimerInterval(); } lastStreamInfoRefresh = DateTime.Now; TwitchStreamInfoChanged?.Invoke(this, new TwitchStreamInfoEventArgs(lastStreamInfo)); return; } catch (Exception ex) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"GetStreamInfo Exception: {ex}"); } } else { Logger.Instance.LogMessage(TracingLevel.WARN, "GetStreamInfo Fetch Failed"); } IncreaseTimerInterval(); TwitchStreamInfoChanged?.Invoke(this, new TwitchStreamInfoEventArgs(null)); } }
public TwitchStreamInfoEventArgs(TwitchStreamInfo streamInfo) { StreamInfo = streamInfo; }