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();
    payloadBytesRead += topic.length + 2; // +2 = Mqtt string length bytes
    addSubscription(topic);
  }
}