Unsubscribe Method
Unsubscribes the component from the specified topic.
Syntax
public func unsubscribe(topicId: String, topicIdType: Int32) throws -> Void
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