readFrom method

  1. @override
void readFrom(
  1. MqttByteBuffer payloadStream
)
override

Creates a payload from the specified header stream.

Implementation

@override
void readFrom(MqttByteBuffer payloadStream) {
  var payloadBytesRead = 0;
  final payloadLength = header!.messageSize - variableHeader!.length;
  // Read all the topics and qos subscriptions from the message payload
  while (payloadBytesRead < payloadLength) {
    final topic = payloadStream.readMqttStringM();
    final qos = MqttUtilities.getQosLevel(payloadStream.readByte());
    payloadBytesRead +=
        topic.length + 3; // +3 = Mqtt string length bytes + qos byte
    addSubscription(topic, qos);
  }
}