コード例 #1
0
        /// <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());
                }
            }
        }
コード例 #2
0
 Action <bool> onNextFn(AsyncServerStreamingCall <Example.HelloReply> call)
 {
     return(ok =>
     {
         if (ok)
         {
             replyCount++;
             Example.HelloReply helloReply = call.ResponseStream.Current;
             Debug.Log("Got " + replyCount.ToString() + " greeting, I think: " + helloReply.Message);
             call.ResponseStream.MoveNext().StartAsCoroutine <bool>(this.onNextFn(call));
         }
         else
         {
             Debug.Log("End of stream or failure. Status: " + call.GetStatus() + ". Retrying!");
             call.Dispose();
         }
     });
 }
コード例 #3
0
 public Status GetStatus()
 {
     return(m_Call.GetStatus());
 }