public void ProcessSentFrame(IFrame frame) { switch (State) { case StreamState.Idle: if (frame.Type == FrameType.PushPromise) { State = StreamState.ReservedLocal; } else if (frame.Type == FrameType.Headers) { State = StreamState.Open; } break; case StreamState.ReservedLocal: if (frame.Type == FrameType.Headers) { State = StreamState.HalfClosedRemote; } else if (frame.Type == FrameType.RstStream) { State = StreamState.Closed; } break; case StreamState.HalfClosedRemote: if (frame.IsEndStream || frame.Type == FrameType.RstStream) { State = StreamState.Closed; } break; case StreamState.Open: if (frame.IsEndStream) { State = StreamState.HalfClosedLocal; } if (frame.Type == FrameType.RstStream) { State = StreamState.Closed; } break; case StreamState.ReservedRemote: if (frame.Type == FrameType.RstStream) { State = StreamState.Closed; } break; case StreamState.HalfClosedLocal: if (frame.Type == FrameType.RstStream) { State = StreamState.Closed; } break; } // If data frame, decrease available window if (frame.Type == FrameType.Data) { var windowDecrement = ((DataFrame)frame).PayloadLength; flowControlStateManager.DecreaseWindowSize(frame.StreamIdentifier, windowDecrement); } // Raise the event if (OnFrameSent != null) { OnFrameSent.Invoke(frame); } }
public void ProcessSentFrame(IFrame frame) { SentFrames.Add(frame); if (State == StreamState.Idle) { if (frame.Type == FrameType.PushPromise) { State = StreamState.ReservedLocal; } else if (frame.Type == FrameType.Headers) { State = StreamState.Open; } } else if (State == StreamState.ReservedLocal) { if (frame.Type == FrameType.Headers) { State = StreamState.HalfClosedRemote; } else if (frame.Type == FrameType.RstStream) { State = StreamState.Closed; } } else if (State == StreamState.HalfClosedRemote) { if (frame.IsEndStream || frame.Type == FrameType.RstStream) { State = StreamState.Closed; } } else if (State == StreamState.Open) { if (frame.IsEndStream) { State = StreamState.HalfClosedLocal; } if (frame.Type == FrameType.RstStream) { State = StreamState.Closed; } } else if (State == StreamState.ReservedRemote) { if (frame.Type == FrameType.RstStream) { State = StreamState.Closed; } } else if (State == StreamState.HalfClosedLocal) { if (frame.Type == FrameType.RstStream) { State = StreamState.Closed; } } // If data frame, decrease available window if (frame.Type == FrameType.Data) { var windowDecrement = ((DataFrame)frame).PayloadLength; flowControlStateManager.DecreaseWindowSize(frame.StreamIdentifier, (uint)windowDecrement); } // Raise the event OnFrameSent?.Invoke(frame); }