public IAsyncEnumerable <TResponse> CreateStream <TResponse>(
        IStreamRequest <TResponse> request,
        CancellationToken cancellationToken = default)
    {
        var cancellationTokenToUse = GetCustomOrDefaultCancellationToken(cancellationToken);

        return(_mediator.CreateStream(request, cancellationTokenToUse));
    }
示例#2
0
    public override async Task ListRockets(ListRocketsRequest request, IServerStreamWriter <RocketModel> responseStream, ServerCallContext context)
    {
        var mRequest = _mapper.Map <ListRockets.Request>(request);

        await foreach (var item in _mediator.CreateStream(mRequest, context.CancellationToken))
        {
            await responseStream.WriteAsync(_mapper.Map <RocketModel>(item));
        }
    }
 public async Task OnGet()
 {
     Rockets = await _mediator.CreateStream(new ListRockets.Request(null)).ToListAsync(HttpContext.RequestAborted);
 }