getWriteLength method

int getWriteLength()

Gets the length of the write data when WriteTo will be called. A subclass that overrides writeTo must also overwrite this method.

Implementation

int getWriteLength() {
  var headerLength = 0;
  final enc = MqttEncoding();
  headerLength += enc.getByteCount(protocolName);
  headerLength += 1; // protocolVersion
  headerLength += MqttConnectFlags.getWriteLength();
  headerLength += 2; // keepAlive
  headerLength += 1; // returnCode
  headerLength += enc.getByteCount(topicName.toString());
  headerLength += 2; // MessageIdentifier
  return headerLength;
}