parseHeader static method
Implementation
static Header parseHeader(InputStream input) {
assert(input.byteLength >= headerSize);
// Treat 4-bytes magic as an Int
final magic = input.readInt();
if (magic != magicLittleEndian) {
throw Exception('BadMagicException: 0x${magic.hex8}');
}
final pv = input.readProtocol();
checkSupportedProtocol(pv);
final ev = input.readEncoding();
checkSupportedEncoding(ev);
//
final type = input.readMessageType();
final compress = input.readBool();
assert(compress == false);
int size = input.readInt();
if (size < headerSize) {
throw IllegalMessageSizeException();
}
// if (size > messageSizeMax)
if (size != input.byteLength) {
// input.resize
// read(more)
assert(false, 'TODO: data size < message size');
}
return Header(
magic: magic,
protocol: pv,
encoding: ev,
type: type,
compress: compress,
size: size,
);
}