onUnidirectionalStreamData method
Process received data on a unidirectional stream.
Reads the first varint as the StreamType identifier, then parses the remaining bytes as HTTP/3 frames and dispatches them via onStreamFrame. QPACK encoder and decoder streams are handled separately.
Implementation
void onUnidirectionalStreamData(int streamId, Uint8List data) {
if (data.isEmpty) return;
final typeLength = VarInt.decodeLength(data[0]);
if (data.length < typeLength) return;
final typeValue = VarInt.decode(data.buffer);
final streamType = StreamType.fromValue(typeValue);
if (streamType == null) return;
switch (streamType) {
case StreamType.qpackEncoder:
_encoderStreamId ??= streamId;
_handleQpackEncoderStream(data, offset: typeLength);
return;
case StreamType.qpackDecoder:
_decoderStreamId ??= streamId;
_handleQpackDecoderStream(data, offset: typeLength);
return;
case StreamType.control:
case StreamType.push:
break;
}
var offset = typeLength;
while (offset < data.length) {
try {
final (frame, consumed) = Http3Frame.parse(data, offset: offset);
onStreamFrame(streamId, frame);
offset += consumed;
} catch (_) {
break;
}
}
}