Example #1
0
        public void loadChat()
        {
            bool completed = false;
            using (WebClientTimeOut wc = new WebClientTimeOut(2000))
            {

                wc.Headers.Add("user-agent", "BlitzChat");
                wc.DownloadStringCompleted += delegate(object a, DownloadStringCompletedEventArgs b)
                {
                    if (b.Error == null)
                    {
                        try
                        {
                            JObject messages = JsonConvert.DeserializeObject<JObject>(b.Result);
                            if (messages != null)
                            {
                                updateMessages(messages);
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.Print("Chat messages deserializing exception: " + e.Message);
                        }
                    }
                    completed = true;
                };
                wc.DownloadStringAsync(new Uri(string.Format(chatUrl, chatId)));
                while (!completed) { 
                    
                    Thread.Sleep(20); 
                }

            }
        }
Example #2
0
 public string getViewers() {
     try
     {
         using (WebClientTimeOut wc = new WebClientTimeOut(1000))
         {
             string info = wc.DownloadString(String.Format(channelInfoUrl, channelName));
             int startIndex = info.IndexOf("{\"userinfo\"");
             info = info.Substring(startIndex, info.Length - startIndex - 1);
             JObject jObj = JsonConvert.DeserializeObject<JObject>(info);
             return jObj["viewers"]["cnt"].ToString();
         }
     }
     catch (Exception e)
     {
         Debug.Print("Exception on parsing viewers on gohaTV: " + e.Message);
         return "0";
     }
 }
Example #3
0
 public string getViewers() {
     try
     {
         using (WebClientTimeOut wc = new WebClientTimeOut(500))
         {
             string info = wc.DownloadString(String.Format(chatUsers, chatId));
             JObject jObj = JsonConvert.DeserializeObject<JObject>(info);
             JArray arr = (JArray)jObj["text"];
             return arr.Count.ToString(); 
         }
     }
     catch (Exception e)
     {
         Debug.Print("Exception on parsing userId from gamersTV: " + e.Message);
         return "0";
     }
 }