Пример #1
0
        public void CanGetBlockCount()
        {
            IBitcoinClient      client = new BitcoinClient(ConfigUtility.GetConnectionInfo());
            IRpcResponse <long> resp   = client.GetBlockCount();

            Assert.AreEqual("0", resp.Id);
            Assert.IsTrue(resp.Result > 0);
            //Console.Write(resp.ToString());
        }
Пример #2
0
 public void SetResponse(IRpcResponse response)
 {
     if (response.Exception == null)
     {
         try {
             tsc.SetResult(response.GetResult <T>());
         } catch (Exception ex) {
             tsc.SetException(ex);
         }
     }
     else
     {
         tsc.SetException(response.Exception);
     }
 }
Пример #3
0
        static async Task HandleCommand(dynamic input, IRpcResponse <string> response)
        {
            record["status"] = "Handling command";
            Console.WriteLine(input.command);

            ProcessStartInfo psi = new ProcessStartInfo();

            psi.FileName        = "node";
            psi.Arguments       = input.commandParams;
            psi.UseShellExecute = true;


            Process proc = new Process
            {
                StartInfo = psi
            };

            proc.Start();

            response.Send("Process completed");
            record["status"] = "Completed";
        }
Пример #4
0
        static async Task HandleCommand(string input, IRpcResponse <string> response)
        {
            if (string.IsNullOrEmpty(input))
            {
                response.Error("invalid input");
            }

            if (false)
            {
                response.Reject();
            }

            switch (input)
            {
            case "runProcess":
                await RunProcess();

                break;
            }

            response.Send(input);
        }
Пример #5
0
 public RpcRequestResponse(T1 request, IRpcResponse <T2> response)
 {
     this.Request  = request;
     this.Response = response;
 }
Пример #6
0
 public void OnResponse(IRpcResponse result)
 {
     pendingRequests.TryGetValue(result.Id, out var found);
     pendingRequests.Remove(result.Id);
     found.SetResponse(result);
 }