Пример #1
0
        public Task Process(StreamingRequest streamingRequest)
        {
            if (streamingRequest.GetType() != typeof(HttpStreamingRequest))
            {
                throw new ArgumentException($"{nameof(HttpStreamingRequest)} is required.");
            }

            var req         = streamingRequest as HttpStreamingRequest;
            var httpContext = req.HttpContext;
            var provider    = _streamingProviderManager.Get(req.Name);

            HttpResponseMessage res = new HttpResponseMessage();

            res.Content = new PushStreamContent((responseStream, httpContent, context) =>
            {
                provider.RegisterOutput(responseStream, req.CancellationToken);
            }, provider.MediaType);

            return(res.Content.CopyToAsync(httpContext.Response.Body));
        }