您的位置:首页 > 编程语言 > Qt开发

Mqtt精髓系列之发布订阅

2017-11-30 10:44 369 查看
翻译:https://www.hivemq.com/blog/mqtt-essentials-part-4-mqtt-publish-subscribe-unsubscribe

发布Publish



QoS

  客户端发布到Broker的消息Qos;

Retain-Flag

  当前发布的消息是否为保留消息;

消息ID Packet Identifier

消息ID只在Qos>0时使用,且范围为0~65535,尽可能减少了消息头;(协议涉设计者认为消息流不可能出现有65535条消息没得到确认,一旦确认消息ID即可重复使用)

客户端发布到Broker时,由客户端设置消息ID,Broker投递到客户端时由Broker设置消息ID;

DUP flag

  消息是否重发的标识

订阅Subscribe

  客户端为了接受到订阅消息,必须发送订阅消息SUBSCRIBE,进行动态Topic订阅,SUBSCRIBE消息组成如下图所示:



List of Subscriptions

  订阅关系由Topic+Qos组成,Subscribe中可以包含任意的订阅关系。当订阅关系出现重叠时,选取高level的Qos

A SUBSCRIBE message can contain an arbitrary number of subscriptions for a client. Each subscription is a pair of a topic topic and QoS level. The topic in the subscribe message can also contain wildcards, which makes it possible to subscribe to certain topic patterns. If there are overlapping subscriptions for one client, the highest QoS level for that topic wins and will be used by the broker for delivering the message.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: