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


Python MQTTClient.is_connected方法代码示例

本文整理汇总了Python中Adafruit_IO.MQTTClient.is_connected方法的典型用法代码示例。如果您正苦于以下问题:Python MQTTClient.is_connected方法的具体用法?Python MQTTClient.is_connected怎么用?Python MQTTClient.is_connected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Adafruit_IO.MQTTClient的用法示例。


在下文中一共展示了MQTTClient.is_connected方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_connect

# 需要导入模块: from Adafruit_IO import MQTTClient [as 别名]
# 或者: from Adafruit_IO.MQTTClient import is_connected [as 别名]
 def test_connect(self):
     # Create MQTT test client.
     client = MQTTClient(self.get_test_username(), self.get_test_key())
     # Verify on_connect handler is called and expected client is provided.
     def on_connect(mqtt_client):
         self.assertEqual(mqtt_client, client)
     client.on_connect = on_connect
     # Connect and wait until on_connect event is fired.
     client.connect()
     self.wait_until_connected(client)
     # Verify connected.
     self.assertTrue(client.is_connected())
开发者ID:Mecabot,项目名称:io-client-python,代码行数:14,代码来源:test_mqtt_client.py

示例2: test_disconnect

# 需要导入模块: from Adafruit_IO import MQTTClient [as 别名]
# 或者: from Adafruit_IO.MQTTClient import is_connected [as 别名]
 def test_disconnect(self):
     # Create MQTT test client.
     client = MQTTClient(self.get_test_username(), self.get_test_key())
     # Verify on_connect handler is called and expected client is provided.
     def on_disconnect(mqtt_client):
         self.assertEqual(mqtt_client, client)
     client.on_disconnect = on_disconnect
     # Connect and wait until on_connect event is fired.
     client.connect()
     self.wait_until_connected(client)
     # Now disconnect and wait until disconnection event occurs.
     client.disconnect()
     self.wait_until_connected(client, connect_value=False)
     # Verify diconnected.
     self.assertFalse(client.is_connected())
开发者ID:adafruit,项目名称:io-client-python,代码行数:17,代码来源:test_mqtt_client.py

示例3: test_secure_connect

# 需要导入模块: from Adafruit_IO import MQTTClient [as 别名]
# 或者: from Adafruit_IO.MQTTClient import is_connected [as 别名]
 def test_secure_connect(self):
     """Test a secure (port 8883, TLS enabled) AIO connection
     """
     # Create MQTT-Secure test client.
     client = MQTTClient(self.get_test_username(), self.get_test_key())
     # Verify on_connect handler is called and expected client is provided.
     def on_connect(mqtt_client):
         self.assertEqual(mqtt_client, client)
     client.on_connect = on_connect
     # Connect and wait until on_connect event is fired.
     client.connect()
     self.wait_until_connected(client)
     # Verify connected.
     self.assertTrue(client.is_connected())
     self.assertTrue(client._secure)
开发者ID:adafruit,项目名称:io-client-python,代码行数:17,代码来源:test_mqtt_client.py

示例4: test_insecure_connect

# 需要导入模块: from Adafruit_IO import MQTTClient [as 别名]
# 或者: from Adafruit_IO.MQTTClient import is_connected [as 别名]
 def test_insecure_connect(self):
     """Test an insecure (port 1883, TLS disabled) AIO connection
     """
     # Create MQTT-Insecure (non-SSL) test client.
     client = MQTTClient(self.get_test_username(), self.get_test_key(), secure=False)
     # Verify on_connect handler is called and expected client is provided.
     def on_connect(mqtt_client):
         self.assertEqual(mqtt_client, client)
     client.on_connect = on_connect
     # Connect and wait until on_connect event is fired.
     client.connect()
     self.wait_until_connected(client)
     # Verify connected.
     self.assertTrue(client.is_connected())
     # Verify insecure connection established
     self.assertFalse(client._secure)
开发者ID:adafruit,项目名称:io-client-python,代码行数:18,代码来源:test_mqtt_client.py

示例5: test_create_client

# 需要导入模块: from Adafruit_IO import MQTTClient [as 别名]
# 或者: from Adafruit_IO.MQTTClient import is_connected [as 别名]
 def test_create_client(self):
     # Create MQTT test client.
     client = MQTTClient(self.get_test_username(), self.get_test_key())
     # Verify not connected by default.
     self.assertFalse(client.is_connected())
开发者ID:adafruit,项目名称:io-client-python,代码行数:7,代码来源:test_mqtt_client.py


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