readMqttString static method

String readMqttString(
  1. MqttByteBuffer buffer
)

Reads an MQTT string from the underlying stream.

Implementation

static String readMqttString(MqttByteBuffer buffer) {
  // Read and check the length
  final lengthBytes = buffer.read(2);
  final enc = MqttEncoding();
  final stringLength = enc.getCharCount(lengthBytes);
  final stringBuff = buffer.read(stringLength);
  return enc.getString(stringBuff);
}