detectPacketLevel method
Implementation
EncryptionLevel detectPacketLevel(Uint8List pkt) {
final firstByte = pkt[0];
final isLong = (firstByte & 0x80) != 0;
if (!isLong) {
return EncryptionLevel.application;
}
final typeBits = (firstByte >> 4) & 0x03;
switch (typeBits) {
case 0x00:
return EncryptionLevel.initial;
case 0x02:
return EncryptionLevel.handshake;
default:
throw StateError(
"Unsupported long-header packet type: 0x${typeBits.toRadixString(16)}",
);
}
}