コード例 #1
0
ファイル: Timers.cs プロジェクト: szitus2/Locsi
        public async Task SaveTimers()
        {
            ArrayClassForJSON dd = new ArrayClassForJSON();

            dd.timers = tims;
            string     jsonString = JsonConvert.SerializeObject(dd);
            HttpClient client     = new HttpClient();

            System.Uri          uri     = new Uri("http://" + Common.Instance.LocsiHostname + "/settimers");
            HttpContent         content = new StringContent(jsonString);
            HttpResponseMessage resp    = await client.PostAsync(uri, content);
        }
コード例 #2
0
ファイル: Timers.cs プロジェクト: szitus2/Locsi
        public async Task GetTimers()
        {
            try
            {
                HttpClient client = new HttpClient();

                System.Uri          uri      = new System.Uri("http://" + Common.Instance.LocsiHostname + "/gettimers");
                HttpResponseMessage response = await client.GetAsync(uri);

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();

                    ArrayClassForJSON dd = JsonConvert.DeserializeObject <ArrayClassForJSON>(content);
                    tims = dd.timers;
                }
            }
            catch
            {
                System.Threading.Thread.Sleep(1000);
                await GetTimers();
            }
        }