Exemple #1
0
        public override async Task GetCitiesStream(
            CitiesStreamRequest request,
            IServerStreamWriter <CityReply> responseStream,
            ServerCallContext context)
        {
            var getCitiesInfoPagination = await _cityManager.GetCitiesInfoPagination(request.NumberOfCities, request.PageNumber);

            var cities = _mapper.Map <List <CityReply> >(getCitiesInfoPagination.CityInfos.ToList());

            foreach (var city in cities)
            {
                await responseStream.WriteAsync(city);
            }
        }
Exemple #2
0
        public async IAsyncEnumerable <CityReply> GetCitiesStream(int pageNumber = 1, int numberOfCities = 25)
        {
            var request = new CitiesStreamRequest()
            {
                PageNumber     = pageNumber,
                NumberOfCities = numberOfCities
            };

            using var call = _client.GetCitiesStream(request);

            await foreach (var cityReply in call.ResponseStream.ReadAllAsync())
            {
                yield return(cityReply);
            }
        }