getPacketLength static method

int getPacketLength(
  1. Uint8List buffer, [
  2. int offset = 0
])

Retorna o tamanho total do pacote (cabeçalho de 4 bytes + payload).

Lê os 3 primeiros bytes do buffer para calcular payloadLength e soma 4 (bytes do cabeçalho).

Implementation

@pragma('vm:prefer-inline')
static int getPacketLength(Uint8List buffer, [int offset = 0]) {
  if (offset < 0 || offset > buffer.length - 4) {
    throw MySQLProtocolException(
      'Truncated MySQL packet header at offset $offset '
      '(buffer length ${buffer.length})',
    );
  }
  return getPayloadLength(buffer, offset) + 4;
}