1. First of all, what you list is the definition of message type in the fixed header of the message distributed by the server in the MQTT protocol.
In fact, this is unified in most open source implementations and has no practical significance. It is mainly based on these types to do some business processing. For example, when you receive a request to connect MQTT_CONNECT时候,初始化资源; 在断开连接MQTT_DISCONNECT, you do some finishing work, such as finding that the connection has been disconnected in the app, and actively pushing a message to the app to tell the app that the connection has been disconnected and messages cannot be sent;
2. To truly implement business message types, you need to customize them yourself. Define the message type in the payload. Payload is the real business message entity. For example, customization:
Of course, you mainly define the required message type and format based on your own business needs, then convert the above data into data, and place the data in the payload for distribution.
I have just come into contact with the MQTT protocol, and I am doing subscription and distribution on iOS. A superficial understanding provides an idea for mutual exchange and learning. On github, I compiled some materials: https://github.com/wenghengcong/MQTTExplore.
1. First of all, what you list is the definition of message type in the fixed header of the message distributed by the server in the MQTT protocol.
In fact, this is unified in most open source implementations and has no practical significance. It is mainly based on these types to do some business processing. For example, when you receive a request to connect
MQTT_CONNECT
时候,初始化资源;在断开连接
MQTT_DISCONNECT
, you do some finishing work, such as finding that the connection has been disconnected in the app, and actively pushing a message to the app to tell the app that the connection has been disconnected and messages cannot be sent;2. To truly implement business message types, you need to customize them yourself. Define the message type in the payload. Payload is the real business message entity.
For example, customization:
Of course, you mainly define the required message type and format based on your own business needs, then convert the above data into data, and place the data in the payload for distribution.
I have just come into contact with the MQTT protocol, and I am doing subscription and distribution on iOS. A superficial understanding provides an idea for mutual exchange and learning.
On github, I compiled some materials: https://github.com/wenghengcong/MQTTExplore.