public static IServiceCollection AddJsRuntimeStream(this IServiceCollection serviceCollection, Action <RemoteJsInteropStreamOptions> configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var options = new RemoteJsInteropStreamOptions(); configuration(options); return(AddJsRuntimeStream(serviceCollection, options)); }
internal RemoteJSInteropStream( IJSRuntime jsRuntime, JsRuntimeStreamInfo jsRuntimeStreamInfo, RemoteJsInteropStreamOptions options, CancellationToken cancellationToken) : base(jsRuntimeStreamInfo) { _jsRuntime = jsRuntime; _jsRuntimeStreamInfo = jsRuntimeStreamInfo; _maxSegmentSize = options.MaxSegmentSize; _segmentFetchTimeout = options.SegmentFetchTimeout; var pipe = new Pipe(new PipeOptions(pauseWriterThreshold: options.MaxBufferSize, resumeWriterThreshold: options.MaxBufferSize)); _pipeReader = pipe.Reader; _fillBufferCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); _ = FillBuffer(pipe.Writer, _fillBufferCts.Token); }
public static IServiceCollection AddJsRuntimeStream(this IServiceCollection services, RemoteJsInteropStreamOptions configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } services.AddScoped <IJSRuntimeStream, JSRuntimeStream>(); services.Configure <RemoteJsInteropStreamOptions>(config => { config.MaxBufferSize = configuration.MaxBufferSize; config.MaxSegmentSize = configuration.MaxSegmentSize; config.SegmentFetchTimeout = configuration.SegmentFetchTimeout; }); return(services); }