Files
DMS/DMS.Infrastructure/Services/Mqtt/MqttDeviceContext.cs

46 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Concurrent;
using DMS.Core.Models;
using DMS.Infrastructure.Interfaces.Services;
namespace DMS.Infrastructure.Services.Mqtt
{
/// <summary>
/// MQTT设备上下文用于存储单个MQTT服务器的连接信息和状态
/// </summary>
public class MqttDeviceContext
{
/// <summary>
/// MQTT服务器配置
/// </summary>
public MqttServer MqttServer { get; set; }
/// <summary>
/// MQTT服务实例
/// </summary>
public IMqttService MqttService { get; set; }
/// <summary>
/// 连接状态
/// </summary>
public bool IsConnected { get; set; }
/// <summary>
/// 重连尝试次数
/// </summary>
public int ReconnectAttempts { get; set; }
/// <summary>
/// 与该MQTT服务器关联的所有变量MQTT别名
/// </summary>
public ConcurrentDictionary<int, VariableMqttAlias> VariableMqttAliases { get; set; }
/// <summary>
/// 构造函数
/// </summary>
public MqttDeviceContext()
{
VariableMqttAliases = new ConcurrentDictionary<int, VariableMqttAlias>();
ReconnectAttempts = 0;
}
}
}