本文整理汇总了Python中mqttcli.MqttClient.socket_close方法的典型用法代码示例。如果您正苦于以下问题:Python MqttClient.socket_close方法的具体用法?Python MqttClient.socket_close怎么用?Python MqttClient.socket_close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mqttcli.MqttClient
的用法示例。
在下文中一共展示了MqttClient.socket_close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_001
# 需要导入模块: from mqttcli import MqttClient [as 别名]
# 或者: from mqttcli.MqttClient import socket_close [as 别名]
def test_001(self):
monitor = MqttClient("monitor:{seq}", connect=4)
# NOTE: '/' prefix skips $ messages
# TODO: remove it when '$' filter will be impl.
monitor.subscribe("/#", qos=0)
client = MqttClient("rabbit:{seq}", connect=4)
# close socket without disconnection
client.socket_close()
evt = monitor.recv()
if evt != None:
debug(evt)
return False
monitor.disconnect()
return True
示例2: test_002
# 需要导入模块: from mqttcli import MqttClient [as 别名]
# 或者: from mqttcli.MqttClient import socket_close [as 别名]
def test_002(self):
monitor = MqttClient("monitor:{seq}", connect=4)
# NOTE: '/' prefix skips $ messages
# TODO: remove it when '$' filter will be impl.
monitor.subscribe("/#", qos=0)
client = MqttClient("rabbit:{seq}")
will = {'topic': '/node/disconnect', 'message': client.clientid()}
client.connect(version=4, will=will)
# close socket without disconnection
client.socket_close()
evt = monitor.recv()
if not isinstance(evt, EventPublish) or evt.msg.topic != will['topic'] or \
evt.msg.payload != will['message']:
debug(evt)
return False
monitor.disconnect()
return True
示例3: test_012
# 需要导入模块: from mqttcli import MqttClient [as 别名]
# 或者: from mqttcli.MqttClient import socket_close [as 别名]
def test_012(self):
monitor = MqttClient("monitor:{seq}", connect=4)
# NOTE: '/' prefix skips $ messages
# TODO: remove it when '$' filter will be impl.
monitor.subscribe("/#", qos=2)
client = MqttClient("rabbit:{seq}") # no keepalive
will = {'topic': '/node/disconnect', 'message': client.clientid(), 'retain': True}
client.connect(version=4, will=will)
client.socket_close()
evt = monitor.recv()
if not isinstance(evt, EventPublish) or evt.msg.topic != will['topic'] or \
evt.msg.payload != will['message'] or \
evt.msg.qos != 0:
debug(evt)
return False
if not evt.msg.retain:
debug("evt remain flag set")
return False
monitor.disconnect()
return True