public async ValueTask <MultiplexedConnectionContext?> AcceptAsync(IFeatureCollection?features = null, CancellationToken cancellationToken = default) { if (_listener == null) { throw new InvalidOperationException($"The listener needs to be initialized by calling {nameof(CreateListenerAsync)}."); } try { var quicConnection = await _listener.AcceptConnectionAsync(cancellationToken); if (!_pendingConnections.TryGetValue(quicConnection, out var connectionContext)) { throw new InvalidOperationException("Couldn't find ConnectionContext for QuicConnection."); } else { _pendingConnections.Remove(quicConnection); } // Verify the connection context was created and set correctly. Debug.Assert(connectionContext != null); Debug.Assert(connectionContext.GetInnerConnection() == quicConnection); QuicLog.AcceptedConnection(_log, connectionContext); return(connectionContext); } catch (QuicException ex) when(ex.QuicError == QuicError.OperationAborted) { QuicLog.ConnectionListenerAborted(_log, ex); } return(null); }
public async ValueTask <MultiplexedConnectionContext?> AcceptAsync(IFeatureCollection?features = null, CancellationToken cancellationToken = default) { try { var quicConnection = await _listener.AcceptConnectionAsync(cancellationToken); var connectionContext = new QuicConnectionContext(quicConnection, _context); QuicLog.AcceptedConnection(_log, connectionContext); return(connectionContext); } catch (QuicOperationAbortedException ex) { _log.LogDebug($"Listener has aborted with exception: {ex.Message}"); } return(null); }