private void UpdatePing(Responce responce) { Application.Current.Dispatcher.Invoke(new Action(() => { var match = items.SingleOrDefault(x => x.Id == responce.SockId); double?lag = responce.Data.First() as double?; match.Lag = (int)lag; lvServers.Items.Refresh(); })); }
public Responce <T> Get <T>(string url) where T : new() { var request = new RestRequest(url, Method.GET); var data = Client.Execute <T>(request); var responce = new Responce <T>() { StatusCode = data.StatusCode, Content = data.Data }; return(responce); }
private void UpdateInfo(Responce responce) { Application.Current.Dispatcher.Invoke(new Action(() => { var match = items.SingleOrDefault(x => x.Id == responce.SockId); String Info = responce.Data.First() as String; String RemoteIP = responce.Data[1] as String; match.ComputerId = Info; match.IP = RemoteIP; lvServers.Items.Refresh(); })); }
public Responce <dynamic> Post <X>(string url, X data) { var request = new RestRequest("order", Method.POST); var json = request.JsonSerializer.Serialize(data); request.AddParameter("application/json; charset=utf-8", json, ParameterType.RequestBody); var res = Client.Execute <dynamic>(request); var responce = new Responce <dynamic>() { StatusCode = res.StatusCode, Content = res.Data }; return(responce); }
private void OnResponceReceived(object sender, Responce e) { switch (e.Code) { case "Ping": UpdatePing(e); break; case "Request Info": UpdateInfo(e); break; default: break; } }