private void ProcessDataFrame(DataFrame frame)
{
if (this.OnStreamFrame != null)
{
Http2Stream stream = this.streamsStore.GetStreamById(frame.StreamId);
if (stream == null)
{
this.SendRST(frame.StreamId, StatusCode.InvalidStream);
}
else
{
if (stream.Session.IsFlowControlEnabled)
{
//TODO: incomment this when server will be able to handle window update
//if (stream.CurrentWindowBalanceFromServer <= 0)
// this.SendWindowUpdate(stream, stream.Session.CurrentWindowBalanceToServer);
//stream.UpdateWindowBalance(-frame.Data.Length);
}
receivedDataBuffer.AddRange(frame.Data);
if (frame.IsFinal && this.OnStreamFrame != null)
{
this.OnStreamFrame(this, new StreamDataEventArgs(stream, new ProtocolData(receivedDataBuffer.ToArray()), frame.IsFinal));
this.receivedDataBuffer.Clear();
}
}
}
}