Exemple #1
1
 public async Task DivMany(ServerCallContext context, IAsyncStreamReader<DivArgs> requestStream, IServerStreamWriter<DivReply> responseStream)
 {
     await requestStream.ForEach(async divArgs =>
     {
         await responseStream.WriteAsync(DivInternal(divArgs));
     });
 }
Exemple #2
0
 public async Task DivMany(ServerCallContext context, IAsyncStreamReader <DivArgs> requestStream, IServerStreamWriter <DivReply> responseStream)
 {
     await requestStream.ForEach(async divArgs =>
     {
         await responseStream.Write(DivInternal(divArgs));
     });
 }
Exemple #3
0
 public async Task<Num> Sum(ServerCallContext context, IAsyncStreamReader<Num> requestStream)
 {
     long sum = 0;
     await requestStream.ForEach(async num =>
     {
         sum += num.Num_;
     });
     return Num.CreateBuilder().SetNum_(sum).Build();
 }
Exemple #4
0
 public async Task<StreamingInputCallResponse> StreamingInputCall(ServerCallContext context, IAsyncStreamReader<StreamingInputCallRequest> requestStream)
 {
     int sum = 0;
     await requestStream.ForEach(async request =>
     {
         sum += request.Payload.Body.Length;
     });
     return StreamingInputCallResponse.CreateBuilder().SetAggregatedPayloadSize(sum).Build();
 }
Exemple #5
0
        public async Task <StreamingInputCallResponse> StreamingInputCall(ServerCallContext context, IAsyncStreamReader <StreamingInputCallRequest> requestStream)
        {
            int sum = 0;
            await requestStream.ForEach(async request =>
            {
                sum += request.Payload.Body.Length;
            });

            return(StreamingInputCallResponse.CreateBuilder().SetAggregatedPayloadSize(sum).Build());
        }
Exemple #6
0
        public async Task <Num> Sum(ServerCallContext context, IAsyncStreamReader <Num> requestStream)
        {
            long sum = 0;
            await requestStream.ForEach(async num =>
            {
                sum += num.Num_;
            });

            return(Num.CreateBuilder().SetNum_(sum).Build());
        }
Exemple #7
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);
         }
     });
 }
Exemple #8
0
        private static async Task <string> ConcatAndEchoHandler(ServerCallContext context, IAsyncStreamReader <string> requestStream)
        {
            string result = "";
            await requestStream.ForEach(async (request) =>
            {
                if (request == "THROW")
                {
                    throw new Exception("This was thrown on purpose by a test");
                }
                result += request;
            });

            // simulate processing takes some time.
            await Task.Delay(250);

            return(result);
        }
Exemple #9
0
 private static async Task<string> ConcatAndEchoHandler(IAsyncStreamReader<string> requestStream, ServerCallContext context)
 {
     string result = "";
     await requestStream.ForEach(async (request) =>
     {
         if (request == "THROW")
         {
             throw new Exception("This was thrown on purpose by a test");
         }
         result += request;
     });
     // simulate processing takes some time.
     await Task.Delay(250);
     return result;
 }
Exemple #10
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.WriteAsync(response);
         }
     });
 }