Add MQTT runtime control and device data pipeline

This commit is contained in:
zhougf committed 2026-05-31 10:55:22 +08:00
1 parent 96d8309793
commit 8a0aa8f7cb
31 files changed
+30842 -20

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Threading;
namespace HHWMS.Web.Services
{
public class MqttRuntimeState
{
private int _enabled;
public bool Enabled => Volatile.Read(ref _enabled) == 1;
public DateTime? LastChangedAt { get; private set; }
public string LastChangedBy { get; private set; }
public void Update(bool enabled, string changedBy = null)
{
var oldEnabled = Enabled;
Volatile.Write(ref _enabled, enabled ? 1 : 0);
if (oldEnabled != enabled || string.IsNullOrEmpty(LastChangedBy))
{
LastChangedAt = DateTime.Now;
LastChangedBy = changedBy;
}
}
}
}