public MsQuicConnectionListener(MsQuicTransportOptions options, IHostApplicationLifetime lifetime, IMsQuicTrace log, EndPoint endpoint)
 {
     _api = new MsQuicApi();
     _log = log;
     _transportContext = new MsQuicTransportContext(lifetime, _log, options);
     EndPoint          = endpoint;
 }
Beispiel #2
0
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _registration.SessionCloseDelegate?.Invoke(_nativeObjPtr);
            _nativeObjPtr = IntPtr.Zero;
            _registration = null;

            _disposed = true;
        }
Beispiel #3
0
        public MsQuicConnection(MsQuicApi api, MsQuicTransportContext context, IntPtr nativeObjPtr)
        {
            _api          = api;
            _context      = context;
            _log          = context.Log;
            _nativeObjPtr = nativeObjPtr;

            SetCallbackHandler();

            SetIdleTimeout(_context.Options.IdleTimeout);

            Features.Set <IQuicStreamListenerFeature>(this);
            Features.Set <IQuicCreateStreamFeature>(this);

            _log.NewConnection(ConnectionId);
        }
Beispiel #4
0
        public MsQuicStream(MsQuicApi api, MsQuicConnection connection, MsQuicTransportContext context, QUIC_STREAM_OPEN_FLAG flags, IntPtr nativeObjPtr)
        {
            Debug.Assert(connection != null);

            Api           = api;
            _nativeObjPtr = nativeObjPtr;

            _connection = connection;
            MemoryPool  = context.Options.MemoryPoolFactory();
            _log        = context.Log;

            ConnectionClosed = _streamClosedTokenSource.Token;

            var maxReadBufferSize  = context.Options.MaxReadBufferSize.Value;
            var maxWriteBufferSize = context.Options.MaxWriteBufferSize.Value;

            _resettableCompletion = new ResettableCompletionSource(this);

            // TODO should we allow these PipeScheduler to be configurable here?
            var inputOptions  = new PipeOptions(MemoryPool, PipeScheduler.ThreadPool, PipeScheduler.Inline, maxReadBufferSize, maxReadBufferSize / 2, useSynchronizationContext: false);
            var outputOptions = new PipeOptions(MemoryPool, PipeScheduler.Inline, PipeScheduler.ThreadPool, maxWriteBufferSize, maxWriteBufferSize / 2, useSynchronizationContext: false);

            var pair = DuplexPipe.CreateConnectionPair(inputOptions, outputOptions);

            // TODO when stream is unidirectional, don't create an output pipe.
            if (flags.HasFlag(QUIC_STREAM_OPEN_FLAG.UNIDIRECTIONAL))
            {
                Features.Set <IUnidirectionalStreamFeature>(this);
            }

            // TODO populate the ITlsConnectionFeature (requires client certs).
            var feature = new FakeTlsConnectionFeature();

            Features.Set <ITlsConnectionFeature>(feature);

            Transport   = pair.Transport;
            Application = pair.Application;

            SetCallbackHandler();

            _processingTask = ProcessSends();

            // Concatenate stream id with ConnectionId.
            _log.NewStream(ConnectionId);
        }
Beispiel #5
0
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (_nativeObjPtr != IntPtr.Zero)
            {
                _api.ConnectionCloseDelegate?.Invoke(_nativeObjPtr);
            }

            _nativeObjPtr = IntPtr.Zero;
            _api          = null;

            _handle.Free();
            _disposed = true;
        }
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            StopAcceptingConnections();

            if (_nativeObjPtr != IntPtr.Zero)
            {
                _api.ListenerStopDelegate(_nativeObjPtr);
                _api.ListenerCloseDelegate(_nativeObjPtr);
            }

            _nativeObjPtr = IntPtr.Zero;
            _api          = null;
            _disposed     = true;
        }
Beispiel #7
0
 internal QuicSession(MsQuicApi registration, IntPtr nativeObjPtr)
 {
     _registration = registration;
     _nativeObjPtr = nativeObjPtr;
 }
Beispiel #8
0
 public QuicSecConfig(MsQuicApi registration, IntPtr nativeObjPtr)
 {
     _registration = registration;
     NativeObjPtr  = nativeObjPtr;
 }