From c4d58071e2d6ddfb661d6eb3336961c49a65159d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E4=BA=BA=E6=98=93?= Date: Thu, 14 Dec 2023 19:15:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=B6=88=E6=81=AF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=86=E5=8F=91=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NewLife.MQTT/Handlers/IMqttHandler.cs | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/NewLife.MQTT/Handlers/IMqttHandler.cs b/NewLife.MQTT/Handlers/IMqttHandler.cs index d01e64c..4267f36 100644 --- a/NewLife.MQTT/Handlers/IMqttHandler.cs +++ b/NewLife.MQTT/Handlers/IMqttHandler.cs @@ -22,6 +22,14 @@ public interface IMqttHandler /// Task PublishAsync(String topic, Object data, QualityOfService qos = QualityOfService.AtMostOnce); + /// 发布消息 + /// 主题 + /// 消息数据 + /// 服务质量 + /// 允许消息交换 + /// + Task PublishAsync(String topic, Object data, Boolean AllowExchange, QualityOfService qos = QualityOfService.AtMostOnce); + /// 发布消息 /// 消息 /// @@ -176,6 +184,27 @@ public async Task PublishAsync(String topic, Object data, Quality return await PublishAsync(message); } + /// 发布消息 + /// 主题 + /// 消息数据 + /// 服务质量 + /// 允许消息交换 + /// + public async Task PublishAsync(String topic, Object data, Boolean AllowExchange, QualityOfService qos = QualityOfService.AtMostOnce) + { + var pk = data as Packet; + if (pk == null && data != null) pk = Serialize(data); + + var message = new PublishMessage + { + Topic = topic, + Payload = pk, + QoS = qos, + }; + + return await PublishAsync(message); + } + /// 发布消息 /// 消息 ///