Beispiel #1
0
 public async Task DivMany(ServerCallContext context, IAsyncStreamReader <DivArgs> requestStream, IServerStreamWriter <DivReply> responseStream)
 {
     await requestStream.ForEach(async divArgs =>
     {
         await responseStream.Write(DivInternal(divArgs));
     });
 }
Beispiel #2
0
 /// <summary>
 /// Writes all elements from given enumerable to the stream.
 /// </summary>
 public static async Task WriteAll <T>(this IServerStreamWriter <T> streamWriter, IEnumerable <T> elements)
     where T : class
 {
     foreach (var element in elements)
     {
         await streamWriter.Write(element);
     }
 }
Beispiel #3
0
 public async Task StreamingOutputCall(ServerCallContext context, StreamingOutputCallRequest request, IServerStreamWriter <StreamingOutputCallResponse> responseStream)
 {
     foreach (var responseParam in request.ResponseParametersList)
     {
         var response = StreamingOutputCallResponse.CreateBuilder()
                        .SetPayload(CreateZerosPayload(responseParam.Size)).Build();
         await responseStream.Write(response);
     }
 }
Beispiel #4
0
 public async Task FullDuplexCall(ServerCallContext context, IAsyncStreamReader <StreamingOutputCallRequest> requestStream, IServerStreamWriter <StreamingOutputCallResponse> responseStream)
 {
     await requestStream.ForEach(async request =>
     {
         foreach (var responseParam in request.ResponseParametersList)
         {
             var response = StreamingOutputCallResponse.CreateBuilder()
                            .SetPayload(CreateZerosPayload(responseParam.Size)).Build();
             await responseStream.Write(response);
         }
     });
 }
Beispiel #5
0
        public async Task Fib(ServerCallContext context, FibArgs request, IServerStreamWriter <Num> responseStream)
        {
            if (request.Limit <= 0)
            {
                // TODO(jtattermusch): support cancellation
                throw new NotImplementedException("Not implemented yet");
            }

            if (request.Limit > 0)
            {
                foreach (var num in FibInternal(request.Limit))
                {
                    await responseStream.Write(num);
                }
            }
        }