Exemple #1
0
 public void StreamResume(QuicStreamContext streamContext)
 {
     if (_logger.IsEnabled(LogLevel.Debug))
     {
         _streamResume(_logger, streamContext.ConnectionId, null);
     }
 }
Exemple #2
0
 public void StreamAbort(QuicStreamContext streamContext, string reason)
 {
     if (_logger.IsEnabled(LogLevel.Debug))
     {
         _streamAborted(_logger, streamContext.ConnectionId, reason, null);
     }
 }
Exemple #3
0
 public void StreamError(QuicStreamContext streamContext, Exception ex)
 {
     if (_logger.IsEnabled(LogLevel.Debug))
     {
         _streamError(_logger, streamContext.ConnectionId, ex);
     }
 }
Exemple #4
0
 public void AcceptedStream(QuicStreamContext streamContext)
 {
     if (_logger.IsEnabled(LogLevel.Debug))
     {
         _acceptedStream(_logger, streamContext.ConnectionId, null);
     }
 }
        public override async ValueTask <ConnectionContext?> AcceptAsync(CancellationToken cancellationToken = default)
        {
            try
            {
                var stream = await _connection.AcceptStreamAsync(cancellationToken);

                var context = new QuicStreamContext(stream, this, _context);
                context.Start();
                return(context);
            }
            catch (QuicConnectionAbortedException ex)
            {
                // Shutdown initiated by peer, abortive.
                // TODO cancel CTS here?
                _log.LogDebug($"Accept loop ended with exception: {ex.Message}");
            }
            catch (QuicOperationAbortedException)
            {
                // Shutdown initiated by us

                // Allow for graceful closure.
            }

            return(null);
        }
        public override ValueTask <ConnectionContext> ConnectAsync(IFeatureCollection?features = null, CancellationToken cancellationToken = default)
        {
            QuicStream quicStream;

            if (features != null)
            {
                var streamDirectionFeature = features.Get <IStreamDirectionFeature>() !;
                if (streamDirectionFeature.CanRead)
                {
                    quicStream = _connection.OpenBidirectionalStream();
                }
                else
                {
                    quicStream = _connection.OpenUnidirectionalStream();
                }
            }
            else
            {
                quicStream = _connection.OpenBidirectionalStream();
            }

            var context = new QuicStreamContext(quicStream, this, _context);

            context.Start();

            return(new ValueTask <ConnectionContext>(context));
        }
        public ValueTask <ConnectionContext> StartBidirectionalStreamAsync()
        {
            var stream  = _connection.OpenBidirectionalStream();
            var context = new QuicStreamContext(stream, this, _context);

            context.Start();
            return(new ValueTask <ConnectionContext>(context));
        }