// Outgoing public RstStreamFrame(int id, ResetStatusCode statusCode) : base(new byte[InitialFrameSize], id) { FrameType = ControlFrameType.RstStream; FrameLength = InitialFrameSize - Constants.FramePreambleSize; // 8 StatusCode = statusCode; }
public void Close(ResetStatusCode code) { if (Closed || Idle) { return; } OnFrameSent = null; Http2Logger.LogDebug("Total outgoing data frames volume " + SentDataAmount); Http2Logger.LogDebug("Total frames sent: {0}", FramesSent); Http2Logger.LogDebug("Total frames received: {0}", FramesReceived); if (code == ResetStatusCode.Cancel || code == ResetStatusCode.InternalError) { WriteRst(code); } _flowCrtlManager.StreamClosedHandler(this); Closed = true; if (OnClose != null) { OnClose(this, new StreamClosedEventArgs(_id)); } OnClose = null; Http2Logger.LogDebug("Stream closed " + _id); }
// Outgoing public RstStreamFrame(int id, ResetStatusCode statusCode) : base(new byte[InitialFrameSize]) { StreamId = id; //32 bit FrameType = FrameType.RstStream; //8bit FrameLength = InitialFrameSize - Constants.FramePreambleSize; // 16bit StatusCode = statusCode; //32bit }
// Outgoing public GoAwayFrame(int lastStreamId, ResetStatusCode statusCode) : base(new byte[InitialFrameSize]) { FrameType = FrameType.GoAway; FrameLength = InitialFrameSize - Constants.FramePreambleSize; // 16 bytes LastGoodStreamId = lastStreamId; StatusCode = statusCode; }
// Outgoing public RstStreamFrame(int id, ResetStatusCode statusCode) : base(new byte[InitialFrameSize]) { StreamId = id;//32 bit FrameType = FrameType.RstStream;//8bit FrameLength = InitialFrameSize - Constants.FramePreambleSize; // 16bit StatusCode = statusCode;//32bit }
public void WriteRst(ResetStatusCode code) { var frame = new RstStreamFrame(_id, code); _writeQueue.WriteFrame(frame); ResetSent = true; if (OnFrameSent != null) { OnFrameSent(this, new FrameSentArgs(frame)); } }
/// <summary> /// Writes the go away frame. /// </summary> /// <param name="code">The code.</param> public void WriteGoAway(ResetStatusCode code) { //if there were no streams opened if (_lastId == -1) { _lastId = 0; //then set lastId to 0 as spec tells. (See GoAway chapter) } var frame = new GoAwayFrame(_lastId, code); _writeQueue.WriteFrame(frame); }
/// <summary> /// Writes the GOAWAY frame. /// </summary> /// <param name="code">The Reset Status code.</param> public void WriteGoAway(ResetStatusCode code) { //if there were no streams opened if (_lastId == -1) { _lastId = 0; //then set lastId to 0 as spec tells. (See GoAway chapter) } var frame = new GoAwayFrame(_lastId, code); Http2Logger.LogDebug("Sending GOAWAY frame: stream id={0}, code={1}, last good id={2}", frame.StreamId, frame.StatusCode, frame.LastGoodStreamId); _writeQueue.WriteFrame(frame); }
public void WriteRst(ResetStatusCode code) { if (Closed) { return; } var frame = new RstStreamFrame(_id, code); _writeQueue.WriteFrame(frame); if (OnFrameSent != null) { OnFrameSent(this, new FrameSentEventArgs(frame)); } }
private void Close(ResetStatusCode status) { if (_disposed) { return; } Http2Logger.LogDebug("Session closing"); _disposed = true; // Dispose of all streams foreach (Http2Stream stream in ActiveStreams.Values) { //Cancel all opened streams stream.WriteRst(ResetStatusCode.Cancel); stream.Dispose(); } OnSettingsSent = null; OnFrameReceived = null; OnFrameSent = null; if (!_goAwayReceived) { WriteGoAway(status); if (_writeQueue != null) { _writeQueue.Flush(); _writeQueue.Dispose(); } } _comprProc.Dispose(); _sessionSocket.Close(); if (OnSessionDisposed != null) { OnSessionDisposed(this, null); } OnSessionDisposed = null; Http2Logger.LogDebug("Session closed"); }
public ProtocolError(ResetStatusCode code, string message): base(message) { Code = code; }
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"); }
public void Close(ResetStatusCode code) { if (Closed || Idle) { return; } OnFrameSent = null; Http2Logger.LogDebug("Total outgoing data frames volume " + SentDataAmount); Http2Logger.LogDebug("Total frames sent: {0}", FramesSent); Http2Logger.LogDebug("Total frames received: {0}", FramesReceived); if (code == ResetStatusCode.Cancel || code == ResetStatusCode.InternalError) WriteRst(code); _flowCrtlManager.StreamClosedHandler(this); Closed = true; if (OnClose != null) OnClose(this, new StreamClosedEventArgs(_id)); OnClose = null; Http2Logger.LogDebug("Stream closed " + _id); }
public void WriteRst(ResetStatusCode code) { if (Closed) return; var frame = new RstStreamFrame(_id, code); _writeQueue.WriteFrame(frame); if (OnFrameSent != null) { OnFrameSent(this, new FrameSentEventArgs(frame)); } }
private void Close(ResetStatusCode status) { if (_disposed) return; Http2Logger.LogDebug("Session closing"); _disposed = true; // Dispose of all streams foreach (var stream in ActiveStreams.Values) { //Cancel all opened streams stream.Dispose(ResetStatusCode.Cancel); } if (!_goAwayReceived) WriteGoAway(status); OnSettingsSent = null; OnFrameReceived = null; //Missing GoAway means connection was forcibly closed by the remote ep. This means that we can //send nothing into this connection. No need trying to send GoAway. //Hence we may not check for !_goAwayReceived if (_writeQueue != null) { _writeQueue.Flush(); _writeQueue.Dispose(); } if (_frameReader != null) { _frameReader.Dispose(); _frameReader = null; } 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"); }
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"); }
public ProtocolError(ResetStatusCode code, string message) : base(message) { Code = code; }
private void Close(ResetStatusCode status) { if (_disposed) return; Http2Logger.LogDebug("Session closing"); _disposed = true; // Dispose of all streams foreach (Http2Stream stream in ActiveStreams.Values) { //Cancel all opened streams stream.WriteRst(ResetStatusCode.Cancel); stream.Dispose(); } OnSettingsSent = null; OnFrameReceived = null; OnFrameSent = null; if (!_goAwayReceived) { WriteGoAway(status); if (_writeQueue != null) { _writeQueue.Flush(); _writeQueue.Dispose(); } } _comprProc.Dispose(); _sessionSocket.Close(); if (OnSessionDisposed != null) { OnSessionDisposed(this, null); } OnSessionDisposed = null; Http2Logger.LogDebug("Session closed"); }
public virtual void Reset(ResetStatusCode statusCode) { ResetReceived = true; if (_outputStream != null) { _outputStream.Dispose(); } if (_incomingStream != null && _incomingStream != Stream.Null && !FinReceived) { InputStream inputStream = (InputStream)_incomingStream; inputStream.Abort(statusCode.ToString()); } // Not disposing here because many of the resources may still be in use. }