예제 #1
0
 internal override void OnStop()
 {
     FrameReader.Dispose();
     FrameReader = null;
 }
예제 #2
0
        private void Close(ResetStatusCode status)
        {
            if (_disposed)
            {
                return;
            }

            Http2Logger.LogDebug("Session closing");
            _disposed = true;

            // Dispose of all streams
            foreach (var stream in StreamDictionary.Values)
            {
                //Cancel all opened streams
                stream.Close(ResetStatusCode.None);
            }

            if (!_goAwayReceived)
            {
                WriteGoAway(status);

                //TODO fix delay. wait for goAway send and then dispose WriteQueue
                //Wait for GoAway send
                using (var goAwayDelay = new ManualResetEvent(false))
                {
                    goAwayDelay.WaitOne(500);
                }
            }
            OnSettingsSent  = null;
            OnFrameReceived = null;

            if (_frameReader != null)
            {
                _frameReader.Dispose();
                _frameReader = null;
            }

            if (_writeQueue != null)
            {
                _writeQueue.Flush();
                _writeQueue.Dispose();
            }

            if (_comprProc != null)
            {
                _comprProc.Dispose();
                _comprProc = null;
            }

            if (_ioStream != null)
            {
                _ioStream.Close();
                _ioStream = null;
            }

            if (_pingReceived != null)
            {
                _pingReceived.Dispose();
                _pingReceived = null;
            }

            if (_settingsAckReceived != null)
            {
                _settingsAckReceived.Dispose();
                _settingsAckReceived = null;
            }

            if (OnSessionDisposed != null)
            {
                OnSessionDisposed(this, null);
            }

            OnSessionDisposed = null;

            Http2Logger.LogDebug("Session closed");
        }