subscribe method
Send a topic subscription request
Implementation
Future subscribe(
String? topicName, GetQuery getParams, SetParams? setParams) {
var packet = _packetGenerator.generate(packet_types.Sub, topicName);
var data = packet.data as SubPacketData;
if (topicName == '' || topicName == null) {
topicName = topic_names.TOPIC_NEW;
}
data.get = getParams;
if (setParams != null) {
if (setParams.sub != null) {
data.set?.sub = setParams.sub;
}
if (setParams.desc != null) {
if (Tools.isNewGroupTopicName(topicName)) {
// Full set.desc params are used for new topics only
data.set?.desc = setParams.desc;
} else if (Tools.isP2PTopicName(topicName) &&
setParams.desc?.defacs != null) {
// Use optional default permissions only.
data.set?.desc = TopicDescription(defacs: setParams.desc?.defacs);
}
}
if (setParams.tags != null) {
data.set?.tags = setParams.tags;
}
}
packet.data = data;
return _send(packet);
}