Example #1
0
 /// <summary>
 /// 停止下载
 /// 取消当前正在下载的资源
 /// 清空整个队列
 /// </summary>
 public void StopDownload()
 {
     if (null != httpClient)
     {
         httpClient.Abort();
     }
     downloadSortSet.Clear();
 }
Example #2
0
        public void CloseConnection(string s)
        {
            if (Client != null)
            {
                Client.Abort();
                IsConnected = false;

                Debug.Console(1, this, "Client Disconnected");
            }
        }
Example #3
0
        public string FanTo0()
        {
            var request = new HttpClientRequest();

            request.Url.Parse("http://" + ip + "/control");

            request.RequestType = RequestType.Post;

            request.Header.SetHeaderValue("content-type", "application/x-www-form-urlencoded");
            request.Header.SetHeaderValue("content-length", "17");
            request.Header.SetHeaderValue("connection", "close");

            request.ContentString = "fan=0";

            var response = client.Dispatch(request);

            client.Abort();

            // TODO: Fb Handler

            return(response.ContentString.ToString());
        }
Example #4
0
        public IDisposable HttpPatch(string url, Dictionary <string, string> headers,
                                     Dictionary <string, string> contentDict, Action <string> onResponse)
        {
            var httpClient = new HttpClient();

            if (headers.IsNotNull())
            {
                headers.ForEach((key, value) => { httpClient.Headers.Add(key, value); });
            }

            var jsonForm = new JObject();

            contentDict.ForEach((key, value) => { jsonForm[key] = value; });

            var content = new ByteArrayContent(Encoding.UTF8.GetBytes(jsonForm.ToString()), "application/json");

            httpClient.Patch(new Uri(url), content, (responseContent) => { onResponse(responseContent.Data); });

            return(Disposable.Create(() => httpClient.Abort()));
        }
Example #5
0
 protected override void OnReset()
 {
     m_sent = false;
     m_client.Abort();
 }