当前位置: 首页>>代码示例>>Python>>正文


Python MqttClient.socket_close方法代码示例

本文整理汇总了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
开发者ID:gbour,项目名称:wave,代码行数:19,代码来源:021_lastwill.py

示例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
开发者ID:gbour,项目名称:wave,代码行数:22,代码来源:021_lastwill.py

示例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
开发者ID:gbour,项目名称:wave,代码行数:26,代码来源:021_lastwill.py


注:本文中的mqttcli.MqttClient.socket_close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。