本文整理汇总了Python中mqttcli.MqttClient.subscribe_multi方法的典型用法代码示例。如果您正苦于以下问题:Python MqttClient.subscribe_multi方法的具体用法?Python MqttClient.subscribe_multi怎么用?Python MqttClient.subscribe_multi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mqttcli.MqttClient
的用法示例。
在下文中一共展示了MqttClient.subscribe_multi方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_216
# 需要导入模块: from mqttcli import MqttClient [as 别名]
# 或者: from mqttcli.MqttClient import subscribe_multi [as 别名]
def test_216(self):
pub = MqttClient("conformity-pub:{seq}", connect=4)
sub = MqttClient("conformity-sub:{seq}", connect=4)
ack = sub.subscribe_multi([
("foo/bar", 2),
("bar/baz", 0),
("paper/+/scissor", 1)
])
if not isinstance(ack, EventSuback) or ack.mid != sub.get_last_mid():
debug(ack)
return False
# checking granted qos
if len(ack.granted_qos) != 3 or \
ack.granted_qos[0] != 2 or \
ack.granted_qos[1] != 0 or \
ack.granted_qos[2] != 1:
debug(ack)
return False
return True
示例2: test_031
# 需要导入模块: from mqttcli import MqttClient [as 别名]
# 或者: from mqttcli.MqttClient import subscribe_multi [as 别名]
def test_031(self):
sub = MqttClient("sub:{seq}", connect=4)
ack = sub.subscribe_multi([('foo/+', 1), ('foo/#', 1)])
debug("subscribe_multi response: {0}".format(ack))
pub = MqttClient("pub:{seq}", connect=4)
pub.publish("foo/bar", gen_msg(42), qos=1)
evt = sub.recv()
if not isinstance(evt, EventPublish) or\
evt.msg.topic != 'foo/bar' or\
evt.msg.qos != 1:
debug('failing event: {0}'.format(evt))
return False
sub.puback(evt.msg.mid, read_response=False)
evt = pub.recv()
if evt is not None:
debug('failing event: {0}'.format(evt))
return False
# receive 2d publish
evt = sub.recv()
if not isinstance(evt, EventPublish) or\
evt.msg.topic != 'foo/bar' or\
evt.msg.qos != 1:
debug('failing event: {0}'.format(evt))
return False
sub.puback(evt.msg.mid)
evt = pub.recv()
if not isinstance(evt, EventPuback):
debug('failing event: {0}'.format(evt))
return False
return True