MQTT

谁说胖子不能爱 提交于 2020-02-04 05:01:43

MQTT[1]消息队列遥测传输(Message Queuing Telemetry Transport)

subscribe to a topic and publish messages on that topic. 

The core of the client library is the client class which provides all of the functions to publish messages and subscribe to topics.

Main Client Methods

The paho mqtt client class has several methods.The main ones are:

  • connect() and disconnect()
  • subscribe() and unsubscribe()
  • publish()

Each of these methods is associated with a callback. 

1. create a client instance

client = paho.mqtt.client(client_name)

2. connect to a broker or server

Before you can publish messages or subscribe to topics you need to establish a connection to a broker.

client.conect(host_name)

3. subscribe to a topic

4. publish messages

publish(topic, payload=None, qos=0, retain=False)

 

MQTT meeting:

1. ask for the host address, port, so that you can connect to their broker/server. 

2. what should I subscribe to?

 

 

 

https://www.zhihu.com/question/19801131

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!