コード例 #1
0
        public async Task <T> ExecuteTaskAsync <T>(IRpcRequest rpcrequest)
        {
            var request  = _requestbuilder.ToHttp(rpcrequest);
            var response = await _client.ExecuteAsync <RpcResponse <T> >(request).ConfigureAwait(false);

            return(response.Data.Response);
        }
コード例 #2
0
        /// <summary>  </summary>
        public async Task Call <TRequest, TResponse>(IContext ctx, IRpcRequest <TRequest, TResponse> request, [NotNull] Pipe.ExecuteAsync <TResponse> onResponse, Pipe.ExecuteAsync <Exception>?onError = null) where TRequest : IRpcRequest <TRequest, TResponse>
        {
            var responseBuilder = Pipe.Builder <TResponse>().UseAsync(onResponse);
            var errorBuilder    = onError == null ? null : Pipe.Builder <Exception>().UseAsync(onError);

            await Call(ctx, request, responseBuilder, errorBuilder);
        }
コード例 #3
0
        public RestRequest ToHttp(IRpcRequest request)
        {
            var toto = new LocalRestRequest(Http, Method.POST);

            toto.AddJsonBody(request);

            return(toto);
        }
コード例 #4
0
        public ISshRequest ToSsh(IRpcRequest request)
        {
            if (request.Params != null)
            {
                return(new DefaultSshRequest(
                           $"{Ssh} {request.Service} {request.Method} \"{ToJson(request.Params).Replace("\"", "\\\"")}\""));
            }

            return(new DefaultSshRequest($"{Ssh} {request.Service} {request.Method}"));
        }
コード例 #5
0
        public async Task <T> RunCmd <T>(IRpcRequest request)
        {
            var cmdResult = await _client.ExecuteTaskAsync <T>(request).ConfigureAwait(false);

            return(cmdResult);
        }
コード例 #6
0
ファイル: RpcServer.cs プロジェクト: Silvenga/Yals
        private async Task ProcessRequest(EncounterContext context, IList <IRequestHandlerRegistration> possibleHandlers, IRpcRequest <JToken> message)
        {
            if (!possibleHandlers.Any())
            {
                throw new Exception($"No handlers registered to respond to encounter with method '${message}'."); // TODO Update this exception type.
            }
            if (possibleHandlers.Count > 1)
            {
                throw new Exception($"Multiple handlers registered to respond to encounter with method '${message}'."); // TODO Update this exception type.
            }

            var handler = possibleHandlers.Single();
            var result  = await handler.HandleRequest(context, message.Parameters);
        }
コード例 #7
0
 /// <summary>  </summary>
 public async Task <TResponse> Call <TRequest, TResponse>(IContext ctx, IRpcRequest <TRequest, TResponse> rpc) where TRequest : IRpcRequest <TRequest, TResponse>
 {
     return(await Call <TRequest, TResponse>(ctx, (TRequest)rpc));
 }