Beispiel #1
0
        private bool IsOnline()
        {
            return(true);

            try
            {
                using (var wc = new WebClient())
                {
                    var tempString = wc.DownloadString(p_apiURL);

                    GangOSClient.Trace(string.Format("{0} [{1}]", tempString.Substring(0, 15), tempString.Length));

                    bool live = !String.IsNullOrWhiteSpace(tempString);

                    if (live)
                    {
                        live = !tempString.StartsWith("<!DOCTYPE");
                    }

                    return(live);
                }
            }
            catch (Exception e)
            {
                GangOSClient.Trace(e.Message);
                return(false);
            }
        }
Beispiel #2
0
 public void GetPlayerData(string auth, AsyncCallback callback)
 {
     new Thread(new ThreadStart(() =>
     {
         string url = string.Format("{0}{1}?token={2}", p_apiURL, p_player, auth);
         GangOSClient.Trace(string.Format("Downloading JSON Data from {0}", url));
         callback.Invoke(new JsonAsyncResult(JsonApiHelper.GetJson(url), auth));
     })).Start();
 }
Beispiel #3
0
        public void GetLivestreams(int page, AsyncCallback callback)
        {
            new Thread(new ThreadStart(() =>
            {
                var List = new List <Livestream>();

                GangOSClient.Trace("Getting official stream if live...");

                //Get official Stream
                JObject query = JsonApiHelper.GetJson(string.Format("{0}streams/gangsofspace", p_APIUrl));

                if (query == null)
                {
                    GangOSClient.Trace(ErrorConsts.JSONDownloadError);
                    callback.Invoke(new ListAsyncResult(List));
                }

                if (query["stream"].HasValues)
                {
                    List.Add(new Livestream(query["stream"]));
                    GangOSClient.Trace("Official stream is live.");
                }
                else
                {
                    GangOSClient.Trace("Official stream is offline.");
                }

                GangOSClient.Trace(string.Format("Getting {0} livestreams from page {1}", 10 - List.Count, page));

                //Get streams playing Gangs of Space live
                query = JsonApiHelper.GetJson(string.Format("{0}streams?game={1}&limit={2}&offset={3}", p_APIUrl, "Gangs%20of%20Space", 10 - List.Count, page));

                if (query == null)
                {
                    GangOSClient.Trace(ErrorConsts.JSONDownloadError);
                    callback.Invoke(new ListAsyncResult(List));
                }

                GangOSClient.Trace("JSON Downloaded, parsing...");

                var results = query["streams"];

                foreach (var k in results)
                {
                    List.Add(new Livestream(k));
                    GangOSClient.Trace(string.Format("Added livestream {0} with {1} viewers", List.Last().Username, List.Last().Viewers));
                }

                GangOSClient.Trace(string.Format("Livestream fetch complete, {0} streams returned.", List.Count));

                callback.Invoke(new ListAsyncResult(List));
            })).Start();
        }