Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            GangOSClient.CheckDebug();

            GangOSClient.Initialize();

            Application.Run(mainForm = new MainWindow());
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            var code = textBox1.Text;

            if (code.Length != 64)
            {
                MessageBox.Show("Error: Invalid API Auth Code, please try again.", "Invalid Code",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            GangOSClient.AddPlayer(code);

            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 6
0
        public Livestream(JToken json)
        {
            Username = json["channel"]["name"].ToString();
            Viewers  = int.Parse(json["viewers"].ToString());
            try
            {
                Followers = int.Parse(json["channel"]["followers"].ToString());
            }
            catch
            {
                Followers = 0;
            }

            string imgUrl = json["channel"]["logo"].ToString();

            Avatar = GangOSClient.GetImageFromURL(imgUrl, Username, string.Format("{0}\\Twitch_{1}_Logo.png", "TwitchAvatars", Username), new Size(86, 86));
        }