コード例 #1
0
ファイル: CircuitHost.cs プロジェクト: ilkayilknur/aspnetcore
        // ReceiveJSDataChunk is used in a fire-and-forget context, so it's responsible for its own
        // error handling.
        internal async Task <bool> ReceiveJSDataChunk(long streamId, long chunkId, byte[] chunk, string error)
        {
            AssertInitialized();
            AssertNotDisposed();

            try
            {
                return(await Renderer.Dispatcher.InvokeAsync(() =>
                {
                    return RemoteJSDataStream.ReceiveData(JSRuntime, streamId, chunkId, chunk, error);
                }));
            }
            catch (Exception ex)
            {
                // An error completing JS interop means that the user sent invalid data, a well-behaved
                // client won't do this.
                Log.ReceiveJSDataChunkException(_logger, streamId, ex);
                await TryNotifyClientErrorAsync(Client, GetClientErrorMessage(ex, "Invalid chunk supplied to stream."));

                UnhandledException?.Invoke(this, new UnhandledExceptionEventArgs(ex, isTerminating: false));
                return(false);
            }
        }