code: static int decodeRemainingLenght(ByteBuf in) {
          int multiplier = 1;
          int value = 0;
          byte digit;
          do {
              if (in.readableBytes() < 1) {
                  return -1;
              }
              digit = in.readByte();
              value += (digit & 0x7F) * multiplier;
              multiplier *= 128;
          } while ((digit & 0x80) != 0);
          return value;
      }
docs: Decode the variable remaining length as defined in MQTT v3.1 specification
  (section 2.1).
  
  @return the decoded length or -1 if needed more data to decode the length field.