Files
DMS/DMS.Application/Services/Processors/MqttPublishProcessor.cs

40 lines
1.4 KiB
C#
Raw Normal View History

2025-09-04 13:40:07 +08:00
using System.Threading.Tasks;
using DMS.Application.Interfaces;
using DMS.Application.Models;
using DMS.Core.Models;
namespace DMS.Application.Services.Processors;
/// <summary>
/// 负责将变量数据发布到MQTT的处理器。
/// </summary>
public class MqttPublishProcessor : IVariableProcessor
{
// private readonly MqttBackgroundService _mqttBackgroundService;
//
// public MqttPublishProcessor(MqttBackgroundService mqttBackgroundService)
// {
// _mqttBackgroundService = mqttBackgroundService;
// }
/// <summary>
/// 处理单个变量上下文如果有关联的MQTT配置则将其推送到发送队列。
/// </summary>
/// <param name="context">包含变量及其元数据的上下文对象。</param>
public async Task ProcessAsync(VariableContext context)
{
// var variable = context.Data;
// if (variable?.VariableMqtts == null || variable.VariableMqtts.Count == 0)
// {
// return; // 没有关联的MQTT配置直接返回
// }
//
// // 遍历所有关联的MQTT配置并将其推入发送队列
// foreach (var variableMqtt in variable.VariableMqtts)
// {
// // 确保VariableMqtt对象中包含了最新的Variable数据
// variableMqtt.Variable = variable;
// await _mqttBackgroundService.SendVariableAsync(variableMqtt);
// }
}
}