Пример #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);
        }
        public RestRequest ToHttp(IRpcRequest request)
        {
            var toto = new LocalRestRequest(Http, Method.POST);

            toto.AddJsonBody(request);

            return(toto);
        }
        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}"));
        }
        public async Task <T> RunCmd <T>(IRpcRequest request)
        {
            var cmdResult = await _client.ExecuteTaskAsync <T>(request).ConfigureAwait(false);

            return(cmdResult);
        }
Пример #6
0
        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));
 }