Esempio n. 1
0
        /// <summary>
        /// add the main events.
        /// </summary>
        private void InitializeMainEvents()
        {
            //---------------------------------------------
            this.GameUniverse.MouseDown -= WotoPlanet_MouseDown;
            this.GameUniverse.MouseUp   -= WotoPlanet_MouseUp;
            this.Window.TextInput       -= Window_TextInput;
            this.GameUniverse.MouseDown += WotoPlanet_MouseDown;
            this.GameUniverse.MouseUp   += WotoPlanet_MouseUp;
            this.Window.TextInput       += Window_TextInput;
            //---------------------------------------------
                        #if !SETVER_TEST
            System.Net.Http.HttpClient test = new System.Net.Http.HttpClient();
            test.BaseAddress = new Uri("https://ltw-game.herokuapp.com");
            System.Net.Http.HttpRequestMessage ro = new System.Net.Http.HttpRequestMessage();
            ro.Headers.Add("test", "    HELLO!!!!!!!");
            var _res = test.Send(ro);

            Stream       receiveStream = _res.Content.ReadAsStream();
            StreamReader readStream    = new StreamReader(receiveStream, Encoding.UTF8);
            var          text1         = readStream.ReadToEnd();

            ro   = new System.Net.Http.HttpRequestMessage();
            _res = test.Send(ro);

            receiveStream = _res.Content.ReadAsStream();
            readStream    = new StreamReader(receiveStream, Encoding.UTF8);
            var text2 = readStream.ReadToEnd();
                        #endif
        }
Esempio n. 2
0
        /// <summary>
        /// Get the latest version of MPF from GitHub and the release URL
        /// </summary>
        private static (string tag, string url) GetRemoteVersionAndUrl()
        {
#if NETFRAMEWORK
            using (System.Net.WebClient wc = new System.Net.WebClient())
            {
                wc.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0";

                // TODO: Figure out a better way than having this hardcoded...
                string url = "https://api.github.com/repos/SabreTools/MPF/releases/latest";
                string latestReleaseJsonString = wc.DownloadString(url);
                var    latestReleaseJson       = JObject.Parse(latestReleaseJsonString);
                string latestTag  = latestReleaseJson["tag_name"].ToString();
                string releaseUrl = latestReleaseJson["html_url"].ToString();

                return(latestTag, releaseUrl);
            }
#else
            using (System.Net.Http.HttpClient hc = new System.Net.Http.HttpClient())
            {
                // TODO: Figure out a better way than having this hardcoded...
                string url     = "https://api.github.com/repos/SabreTools/MPF/releases/latest";
                var    message = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Get, url);
                message.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0");
                string latestReleaseJsonString = hc.Send(message)?.Content?.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
                var    latestReleaseJson       = JObject.Parse(latestReleaseJsonString);
                string latestTag  = latestReleaseJson["tag_name"].ToString();
                string releaseUrl = latestReleaseJson["html_url"].ToString();

                return(latestTag, releaseUrl);
            }
#endif
        }