Unsubscribe Method

Unsubscribes the class from the specified topic.

Object Oriented Interface

public function doUnsubscribe($topicid, $topicidtype);

Procedural Interface

ipworksiot_mqttsn_do_unsubscribe($res, $topicid, $topicidtype);

Remarks

This method unsubscribes the class to the TopicId.

TopicIdType indicates the category of value specified in TopicId and may have the following values:

  • 0: Topic name - a full topic name as described in RegisterTopic to be registered by the gateway.
  • 1: Pre-defined topic id - id whose mapping to a topic name is known in advance by both the client and the gateway - no registration is necessary.
  • 2: Short topic name - has a fixed length of two bytes and is short enough that no registration is necessary. To use one, simply set the correct TopicIdType and set the TopicId to a two-character string.

Unsubscribe Examples

String fullTopicName = "full/topic/name";
mqtt1.Unsubscribe(fullTopicName, 0); // unsubscribe from topic name

mqtt1.Unsubscribe(fullTopicName+"/#", 0); // must use full topic filter if includes wildcard; can't unsubscribe from individual topics included in the filter

mqtt1.Unsubscribe("aa", 2); // unsubscribe from short topic

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 PHP Edition - Version 20.0 [Build 8265]