fromBytes static method

StreamFrame fromBytes(
  1. ByteData view,
  2. int offset
)
override

A factory constructor to deserialize a frame from bytes.

Implementation

static StreamFrame fromBytes(ByteData view, int offset) {
  final flags = view.getUint8(offset + 1);
  final isFin = (flags & 0x01) != 0;
  final isSyn = (flags & 0x02) != 0;
  final dataLength = view.getUint16(offset + 2, Endian.big);
  final data = Uint8List.view(view.buffer, view.offsetInBytes + offset + 4, dataLength);
  return StreamFrame(isFin: isFin, isSyn: isSyn, data: data);
}