public async Task DivMany(ServerCallContext context, IAsyncStreamReader <DivArgs> requestStream, IServerStreamWriter <DivReply> responseStream) { await requestStream.ForEach(async divArgs => { await responseStream.Write(DivInternal(divArgs)); }); }
/// <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); } }
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); } }
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); } }); }
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); } } }