/// <exclude />
        public static async IAsyncEnumerable <T> GetServerStreamingCallResult <T>(
            AsyncServerStreamingCall <Message <T> > call,
            CallContext?context,
            [EnumeratorCancellation] CancellationToken token)
        {
            using (call)
            {
                if (context != null && !token.IsCancellationRequested)
                {
                    var headers = await call.ResponseHeadersAsync.ConfigureAwait(false);

                    context.ServerResponse = new ServerResponse(
                        headers,
                        call.GetStatus,
                        call.GetTrailers);
                }

                while (await call.ResponseStream.MoveNext(token).ConfigureAwait(false))
                {
                    yield return(call.ResponseStream.Current.Value1);
                }

                if (context != null && !token.IsCancellationRequested)
                {
                    context.ServerResponse = new ServerResponse(
                        context.ResponseHeaders !,
                        call.GetStatus(),
                        call.GetTrailers());
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Tries to the get call trailers.
 /// </summary>
 /// <typeparam name="TResponse">The type of the response.</typeparam>
 /// <param name="call">The call.</param>
 /// <returns>The trailing metadata, if the call has completed, an empty metadata if the
 /// call is ongoing.</returns>
 /// <remarks>There is currently no exposed method in the gRPC stack to check if an API call
 /// has completed.</remarks>
 private Metadata TryGetCallTrailers <TResponse>(AsyncServerStreamingCall <TResponse> call)
 {
     try
     {
         return(call.GetTrailers());
     }
     catch (InvalidOperationException) {
         return(new Metadata());
     }
 }
Ejemplo n.º 3
0
 public Metadata GetTrailers()
 {
     return(m_Call.GetTrailers());
 }