unsubscribeSubscriptionList method

void unsubscribeSubscriptionList(
  1. List<MqttSubscription>? subscriptions
)

Unsubscribe from a subscription list. Note that user properties are set on a per message basis not a per subscription basis, if you wish to send user properties then set them on the first subscription in the list.

Implementation

void unsubscribeSubscriptionList(List<MqttSubscription>? subscriptions) {
  if (subscriptions == null) {
    throw ArgumentError(
        'MqttSubscriptionManager::unsubscribeSubscriptionList - subscription list is null');
  }
  final unsubscribeMsg = MqttUnsubscribeMessage()
      .withMessageIdentifier(messageIdentifierDispenser.nextMessageIdentifier)
      .fromSubscriptionList(subscriptions)
      .withUserProperties(subscriptions.first.userProperties);
  _connectionHandler.sendMessage(unsubscribeMsg);
  pendingUnsubscriptions[unsubscribeMsg.variableHeader.messageIdentifier] =
      subscriptions;
}