public void CloseDaemon() { try { using (HttpClient client = RpcRoot.Create()) { Task <HttpResponseMessage> getHttpResponse = client.PostAsync($"http://localhost:{NTKeyword.NTMinerDaemonPort.ToString()}/api/{s_controllerName}/{nameof(INTMinerDaemonController.CloseDaemon)}", null); Write.DevDebug($"{nameof(CloseDaemon)} {getHttpResponse.Result.ReasonPhrase}"); } } catch (Exception e) { Write.DevException(e); } }
public void ReportSpeedAsync(string host, SpeedData data, Action <ReportResponse> callback) { Task.Factory.StartNew(() => { TimeSpan timeSpan = TimeSpan.FromSeconds(3); try { using (HttpClient client = RpcRoot.Create()) { // 可能超过3秒钟,查查原因。因为我的网络不稳经常断线。 client.Timeout = timeSpan; Task <HttpResponseMessage> getHttpResponse = client.PostAsJsonAsync($"http://{host}:{NTKeyword.ControlCenterPort.ToString()}/api/{SControllerName}/{nameof(IReportController.ReportSpeed)}", data); ReportResponse response = getHttpResponse.Result.Content.ReadAsAsync <ReportResponse>().Result; callback?.Invoke(response); } } catch (Exception e) { Write.DevException(e); } }); }
public void ReportStateAsync(string host, Guid clientId, bool isMining) { Task.Factory.StartNew(() => { TimeSpan timeSpan = TimeSpan.FromSeconds(3); try { using (HttpClient client = RpcRoot.Create()) { client.Timeout = timeSpan; ReportState request = new ReportState { ClientId = clientId, IsMining = isMining }; Task <HttpResponseMessage> getHttpResponse = client.PostAsJsonAsync($"http://{host}:{NTKeyword.ControlCenterPort.ToString()}/api/{SControllerName}/{nameof(IReportController.ReportState)}", request); Write.DevDebug($"{nameof(ReportStateAsync)} {getHttpResponse.Result.ReasonPhrase}"); } } catch (Exception e) { Write.DevException(e); } }); }
protected override void OnError(ErrorEventArgs e) { _holdSessionIds.Remove(base.ID); base.OnError(e); Write.DevException(e.Exception); }
protected override void OnError(ErrorEventArgs e) { base.OnError(e); Write.DevException(e.Exception); }