Beispiel #1
0
        public JObject HandleRequest(RpcRequestPayload payload)
        {
            JArray _params = null;

            try
            {
                JObject parameters = JArray.Parse(payload.Params);

                if (parameters is JArray)
                {
                    _params = (JArray)parameters;
                }
            }
            catch
            {
            }

            if (_params == null)
            {
                throw new RpcException(-32602, "Error occurred when parsing parameters.");
            }

            JObject result = PluginManager.Singleton.ProcessRpcMethod(null, payload.Method, _params);

            if (result == null)
            {
                result = handler.Process(payload.Method, _params);
            }

            return(result);
        }
Beispiel #2
0
        public async Task <TransferResultDto> TransferAsync(TransferPayloadDto dto)
        {
            var payload  = new RpcRequestPayload <TransferPayloadDto>("transfer", dto);
            var response = await CallAsync <TransferResultDto>(payload);

            return(response.Result);
        }
Beispiel #3
0
        public async Task <IEnumerable <IncomingTransferDto> > QueryIncomingTransfersAsync(IncomingTransferType transferType)
        {
            var payload = new RpcRequestPayload <IncomingTransfersPayload>("incoming_transfers", new IncomingTransfersPayload
            {
                TransferType = transferType
            });
            var response = await CallAsync <IncomingTransferResultDto>(payload);

            return(response.Result.Transfers);
        }
Beispiel #4
0
        private void ProcessRpcReuqest(TcpClientDataReceivedEventArgs e, RpcRequestPayload payload)
        {
            try
            {
                JObject result = HandleRequest(payload);

                SendRpcResponse(e.Session, payload.Guid, result);
            }
            catch (Exception exception)
            {
                SendRpcException(e.Session, payload.Guid, exception);
            }
        }
Beispiel #5
0
        void OnClientDataReceived(object sender, TcpClientDataReceivedEventArgs e)
        {
            if (Settings.Default.DebugMode)
            {
                Log($"RpcAgent recv data, length:{e.DataLength}");
            }

            ; byte[] data = e.Data.Skip(e.DataOffset).Take(e.DataLength).ToArray();
            Message  msg  = data.AsSerializable <Message>();

            if (msg.Command == "rpc-request")
            {
                RpcRequestPayload payload = msg.Payload.AsSerializable <RpcRequestPayload>();

                ProcessRpcReuqest(e, payload);
            }
        }
Beispiel #6
0
 public async Task <RpcResponse <TResult> > CallAsync <TResult>(RpcRequestPayload payload)
 {
     return(await client.CallAsync <TResult>($"{config.Url}/json_rpc", payload));
 }