internal override async ValueTask SendAsync( long streamId, OutgoingFrame frame, bool fin, CancellationToken cancel) { var data = new List <ArraySegment <byte> >(); var ostr = new OutputStream(Encoding, data); FrameType frameType = fin ? FrameType.StreamLast : FrameType.Stream; ostr.WriteByte((byte)frameType); OutputStream.Position sizePos = ostr.StartFixedLengthSize(4); ostr.WriteVarLong(streamId); OutputStream.Position ice2HeaderPos = ostr.Tail; if (frame is OutgoingRequestFrame requestFrame) { ostr.WriteByte((byte)Ice2Definitions.FrameType.Request); } else if (frame is OutgoingResponseFrame responseFrame) { ostr.WriteByte((byte)Ice2Definitions.FrameType.Response); } else { Debug.Assert(false); return; } ostr.WriteSize(frame.Size); int ice2HeaderSize = ostr.Tail.Offset - ice2HeaderPos.Offset; data[^ 1] = data[^ 1].Slice(0, ostr.Tail.Offset); // TODO: Shouldn't this be the job of ostr.Finish()?
/// <summary>Sends the given frame on an existing stream.</summary> internal abstract ValueTask SendAsync(long streamId, OutgoingFrame frame, bool fin, CancellationToken cancel);