Exemple #1
0
 /// <summary>
 /// Отправка данных о ходе
 /// </summary>
 /// <param name="turnData">Данные</param>
 /// <returns></returns>
 public bool SendData(TurnData turnData)
 {
     _restClient.BaseUrl = new System.Uri(Uri);
     turnData.Token      = Token;
     _restRequest.Parameters.Clear();
     _restRequest.Resource      = $"api/Player/direction";
     _restRequest.Method        = Method.POST;
     _restRequest.RequestFormat = DataFormat.Json;
     _restRequest.AddBody(turnData);
     return(_restClient.Execute(_restRequest).IsSuccessful);
 }
Exemple #2
0
        /// <summary>
        /// Асинхронная отправка данных о ходе
        /// </summary>
        /// <param name="turnData">Данные</param>
        /// <returns></returns>
        public bool SendDataAsync(TurnData turnData)
        {
            var result = false;

            _restClient.BaseUrl = new System.Uri(Uri);
            turnData.Token      = Token;
            _restRequest.Parameters.Clear();
            _restRequest.Resource      = $"api/Player/direction";
            _restRequest.Method        = Method.POST;
            _restRequest.RequestFormat = DataFormat.Json;
            _restRequest.AddBody(turnData);
            var response = _restClient.ExecuteAsync(_restRequest, r =>
            {
                if (r.ResponseStatus == ResponseStatus.Completed)
                {
                    result = true;
                }
            });

            return(result);
        }