calculateLength static method

int calculateLength(
  1. Uint8Buffer lengthBytes
)

Calculates the remaining length of an MqttMessage from the bytes that make up the length.

Implementation

static int calculateLength(typed.Uint8Buffer lengthBytes) {
  var remainingLength = 0;
  var multiplier = 1;

  for (final currentByte in lengthBytes) {
    remainingLength += (currentByte & 0x7f) * multiplier;
    multiplier *= 0x80;
  }
  return remainingLength;
}