Exemple #1
0
 public static void DoRequest(string command)
 {
     if (request)
     {
         GameObject       go  = (GameObject)Instantiate(request);
         RequestStatistic req = go.GetComponent <RequestStatistic>();
         req.Command = command;
         req.Session = Session;
     }
 }
Exemple #2
0
        //====== Application methods ======

        //@Headers({ "Content-Type: application/json"})
        //@POST("api/v1/stat")
        //Call<ResponseAppStatistic> getAppStatistic(@Body RequestStatistic requestStatistic);
        public async Task <ResponseAppStatistic> GetAppStatisticAsync(RequestStatistic requestStatistic)
        {
            var uri = new Uri(baseUri + @"api/v1/stat");
            // Сформировать JSON данные
            string jsonContent = JsonConvert.SerializeObject(requestStatistic);
            HttpResponseMessage httpResponse = await cmd.PostAsync(uri, jsonContent);

            ResponseAppStatistic responseAppStatistic = new ResponseAppStatistic();

            if (httpResponse.IsSuccessStatusCode)
            {
                responseAppStatistic = JsonConvert.DeserializeObject <ResponseAppStatistic>(httpResponse.Content.ToString());
            }
            else
            {
                responseAppStatistic.Error   = true;
                responseAppStatistic.ErrCode = "";
                responseAppStatistic.ErrMsg  = "Ошибка HttpClient.";
            }
            return(responseAppStatistic);
        }