Skip to content

Commit

Permalink
发布消息增加分发方法
Browse files Browse the repository at this point in the history
  • Loading branch information
猿人易 committed Dec 14, 2023
1 parent b68acd2 commit c4d5807
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions NewLife.MQTT/Handlers/IMqttHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public interface IMqttHandler
/// <returns></returns>
Task<MqttIdMessage> PublishAsync(String topic, Object data, QualityOfService qos = QualityOfService.AtMostOnce);

/// <summary>发布消息</summary>
/// <param name="topic">主题</param>
/// <param name="data">消息数据</param>
/// <param name="qos">服务质量</param>
/// <param name="AllowExchange">允许消息交换</param>
/// <returns></returns>
Task<MqttIdMessage> PublishAsync(String topic, Object data, Boolean AllowExchange, QualityOfService qos = QualityOfService.AtMostOnce);

/// <summary>发布消息</summary>
/// <param name="message">消息</param>
/// <returns></returns>
Expand Down Expand Up @@ -176,6 +184,27 @@ public async Task<MqttIdMessage> PublishAsync(String topic, Object data, Quality
return await PublishAsync(message);
}

/// <summary>发布消息</summary>
/// <param name="topic">主题</param>
/// <param name="data">消息数据</param>
/// <param name="qos">服务质量</param>
/// <param name="AllowExchange">允许消息交换</param>
/// <returns></returns>
public async Task<MqttIdMessage> 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);
}

/// <summary>发布消息</summary>
/// <param name="message">消息</param>
/// <returns></returns>
Expand Down

0 comments on commit c4d5807

Please sign in to comment.