/// <summary>
        /// Initializes a new instance of the <see cref="Http2MessageHandler"/> class.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="end">TODO</param>
        /// <param name="isSecure"></param>
        /// <param name="cancel">The cancel.</param>
        protected Http2MessageHandler(Stream stream, ConnectionEnd end, bool isSecure, CancellationToken cancel)
        {
            _isSecure = isSecure;

            //09 spec:
            //SETTINGS_ENABLE_PUSH (2):  This setting can be use to disable server
            //push (Section 8.2).  An endpoint MUST NOT send a PUSH_PROMISE
            //frame if it receives this setting set to a value of 0.  The
            //initial value is 1, which indicates that push is permitted.

            _isPushEnabled = true;
            _isDisposed = false;
            _cancToken = cancel;
            _stream = stream;
            _end = end;
            _wereFirstSettingsSent = false;

            _session = new Http2Session(_stream, _end, true, true, _isSecure, _cancToken);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Http2MessageHandler"/> class.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="end">TODO</param>
        /// <param name="isSecure"></param>
        /// <param name="cancel">The cancel.</param>
        protected Http2MessageHandler(Stream stream, ConnectionEnd end, bool isSecure, CancellationToken cancel)
        {
            _isSecure = isSecure;

            //09 spec:
            //SETTINGS_ENABLE_PUSH (2):  This setting can be use to disable server
            //push (Section 8.2).  An endpoint MUST NOT send a PUSH_PROMISE
            //frame if it receives this setting set to a value of 0.  The
            //initial value is 1, which indicates that push is permitted.

            _isPushEnabled         = true;
            _isDisposed            = false;
            _cancToken             = cancel;
            _stream                = stream;
            _end                   = end;
            _wereFirstSettingsSent = false;

            _session = new Http2Session(_stream, _end, true, true, _isSecure, _cancToken);
        }
        /// <summary>
        /// Starts the session.
        /// </summary>
        /// <param name="end">The connection end.</param>
        /// <param name="initRequest">The initialize request params.</param>
        /// <returns></returns>
        public Task StartSessionAsync(IDictionary<string, string> initRequest = null)
        {
            int initialWindowSize = 200000;
            int maxStreams = 100;

            if (initRequest != null && initRequest.ContainsKey(":initial_window_size"))
            {
                initialWindowSize = int.Parse(initRequest[":initial_window_size"]);
            }

            if (initRequest != null && initRequest.ContainsKey(":max_concurrent_streams"))
            {
                maxStreams = int.Parse(initRequest[":max_concurrent_streams"]);
            }

            //TODO provide cancellation token and transport info
            _session = new Http2Session(_stream, _end, true, true, _isSecure, _cancToken, initialWindowSize, maxStreams);
            _session.OnFrameReceived += OnFrameReceivedHandler;
            _session.OnSettingsSent += OnSettingsSentHandler;

            return Task.Run(async () => await _session.Start(initRequest));
        }