Beispiel #1
0
        public void Execute()
        {
            // async로 실행되기를 희망함

            Task <String> task = PineRipplePayment.ExecuteAsync(
                this
                );

            task.Wait();
            String msg = task.Result;

            Message = msg;
        }
Beispiel #2
0
        public static async Task <String> ExecuteAsync(PineRipplePayment payment)
        {
            var url = new Uri("http://s2.dotorie.com:8080/transfer");

            //https://stackoverflow.com/questions/4015324/how-to-make-http-post-web-request 참고
            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var values = new Dictionary <string, string>
            {
                { "from", payment.Sender.Wallet.Address },
                { "secret", payment.Sender.Wallet.Secret },
                { "to", payment.Receiver.Wallet.Address },
                { "amount", payment.Amount.ToString() }
            };


            String responseString = "";
            var    content        = new FormUrlEncodedContent(values);

            try
            {
                var response = client.PostAsync(url, content).Result;

                responseString = await response.Content.ReadAsStringAsync();
            }

            catch (Exception ee)
            {
                Console.Write(ee);
            }

            return(responseString);
        }