Exemplo n.º 1
0
 /// <summary>
 /// Invokes a server streaming call asynchronously.
 /// In server streaming scenario, client sends on request and server responds with a
 /// stream of responses.
 /// </summary>
 /// <typeparam name="TRequest">Request message type for this call.</typeparam>
 /// <typeparam name="TResponse">Request message type for this call.</typeparam>
 /// <param name="method">The method details such as service and method names, marshallers
 /// for request and response, etc.</param>
 /// <param name="host">The host to which the call is made.</param>
 /// <param name="options">The call options.</param>
 /// <param name="request">The request object.</param>
 /// <returns>The server streaming call instance.</returns>
 /// <remarks>This method is profiled.</remarks>
 public override AsyncServerStreamingCall <TResponse> AsyncServerStreamingCall <TRequest, TResponse>(
     Method <TRequest, TResponse> method, string host, CallOptions options, TRequest request)
 {
     if (config.EnableProfiling)
     {
         ProfiledMethod <TRequest, TResponse> profiledMethod =
             new ProfiledMethod <TRequest, TResponse>(method, config.EnableProfiling);
         var retval = invoker.AsyncServerStreamingCall(profiledMethod.Method, host,
                                                       options, request);
         profiledMethod.SetMetadataChecker(retval.GetTrailers);
         profiledMethod.SetStatusChecker(retval.GetStatus);
         return(retval);
     }
     return(invoker.AsyncServerStreamingCall(method, host, options, request));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Invokes a simple remote call asynchronously.
        /// </summary>
        /// <typeparam name="TRequest">Request message type for this call.</typeparam>
        /// <typeparam name="TResponse">Request message type for this call.</typeparam>
        /// <param name="method">The method details such as service and method names, marshallers
        /// for request and response, etc.</param>
        /// <param name="host">The host to which the call is made.</param>
        /// <param name="options">The call options.</param>
        /// <param name="request">The request object.</param>
        /// <returns>The async unary call instance.</returns>
        /// <remarks>This method is profiled.</remarks>
        public override AsyncUnaryCall <TResponse> AsyncUnaryCall <TRequest, TResponse>(
            Method <TRequest, TResponse> method, string host, CallOptions options, TRequest request)
        {
            if (config.EnableProfiling)
            {
                ProfiledMethod <TRequest, TResponse> profiledMethod =
                    new ProfiledMethod <TRequest, TResponse>(method, config.EnableProfiling);

                var retval = invoker.AsyncUnaryCall(profiledMethod.Method, host, options, request);
                profiledMethod.SetMetadataChecker(delegate()
                {
                    retval.ResponseHeadersAsync.Wait();
                    return(retval.ResponseHeadersAsync.Result);
                });
                profiledMethod.SetStatusChecker(retval.GetStatus);
                return(retval);
            }
            return(invoker.AsyncUnaryCall(method, host, options, request));
        }