コード例 #1
0
        /// <inheritdoc/>
        public override async Task <TResponse> ClientStreamingServerHandler <TRequest, TResponse>(
            IAsyncStreamReader <TRequest> requestStream,
            ServerCallContext context,
            ClientStreamingServerMethod <TRequest, TResponse> continuation)
        {
            using var rpcScope = new ServerRpcScope <TRequest, TResponse>(context, this.options);

            try
            {
                var requestStreamReaderProxy = new AsyncStreamReaderProxy <TRequest>(
                    requestStream,
                    rpcScope.RecordRequest);

                var response = await continuation(requestStreamReaderProxy, context).ConfigureAwait(false);

                rpcScope.RecordResponse(response);
                rpcScope.Complete();
                return(response);
            }
            catch (Exception e)
            {
                rpcScope.CompleteWithException(e);
                throw;
            }
        }
コード例 #2
0
        /// <inheritdoc/>
        public override async Task <TResponse> UnaryServerHandler <TRequest, TResponse>(
            TRequest request,
            ServerCallContext context,
            UnaryServerMethod <TRequest, TResponse> continuation)
        {
            using var rpcScope = new ServerRpcScope <TRequest, TResponse>(context, this.options);

            try
            {
                rpcScope.RecordRequest(request);
                var response = await continuation(request, context).ConfigureAwait(false);

                rpcScope.RecordResponse(response);
                rpcScope.Complete();
                return(response);
            }
            catch (Exception e)
            {
                rpcScope.CompleteWithException(e);
                throw;
            }
        }