2025-09-16 14:42:23 +08:00
|
|
|
|
using System.Collections.Concurrent;
|
2025-09-06 15:19:04 +08:00
|
|
|
|
using DMS.Core.Models;
|
|
|
|
|
|
using DMS.Infrastructure.Interfaces.Services;
|
|
|
|
|
|
|
2025-09-16 14:42:23 +08:00
|
|
|
|
namespace DMS.Infrastructure.Services.Mqtt
|
2025-09-06 15:19:04 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MQTT设备上下文,用于存储单个MQTT服务器的连接信息和状态
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class MqttDeviceContext
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MQTT服务器配置
|
|
|
|
|
|
/// </summary>
|
2025-10-05 00:28:25 +08:00
|
|
|
|
public MqttServer MqttServerConfig { get; set; }
|
2025-09-06 15:19:04 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MQTT服务实例
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public IMqttService MqttService { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 重连尝试次数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int ReconnectAttempts { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 与该MQTT服务器关联的所有变量MQTT别名
|
|
|
|
|
|
/// </summary>
|
2025-10-18 17:18:09 +08:00
|
|
|
|
public ConcurrentDictionary<int, MqttAlias> MqttAliases { get; set; }
|
2025-09-06 15:19:04 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 构造函数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public MqttDeviceContext()
|
|
|
|
|
|
{
|
2025-10-18 17:18:09 +08:00
|
|
|
|
MqttAliases = new ConcurrentDictionary<int, MqttAlias>();
|
2025-09-06 15:19:04 +08:00
|
|
|
|
ReconnectAttempts = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|