Skip to content

Commit

Permalink
🎨 fixs
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzaz committed Aug 1, 2024
1 parent 58615b6 commit b660dd1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions MqttNet.DependencyInjection/AbsractClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ public AbsractClientHandler(IMqttPublisher mqttPublisher)
/// 心跳接收处理
/// </summary>
/// <param name="heartBeatArgs"></param>
public abstract void HeartBeatReceived(HeartBeatArgs heartBeatArgs);
public abstract Task HeartBeatReceivedAsync(HeartBeatArgs heartBeatArgs);
/// <summary>
/// 信息接收处理
/// </summary>
/// <param name="args"></param>
public abstract void MessageReceived(MessageReceiveArgs args);
public abstract Task MessageReceivedAsync(MessageReceiveArgs args);
/// <summary>
/// 主题订阅
/// </summary>
/// <param name="mqttClient"></param>
/// <returns></returns>
public abstract void SetTopic(out List<ClientTopic> mqttClient);
public abstract void SetTopic(out IEnumerable<ClientTopic> mqttClient);

}
}
10 changes: 5 additions & 5 deletions MqttNetDI.Client/HeartBeat/DynamicSubManagerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ namespace MqttNetDI.Client.HeartBeat
public class DynamicSubManagerService : BackgroundService, IDynamicSubManagerService
{
public Dictionary<string, ClientState> HeartBeatList { get; set; }
public List<ClientTopic> ClientTopics { get; set; }
public IEnumerable<ClientTopic> ClientTopics => _clientTopics;
private readonly IMqttClientCreate _MqttClientCreate;
private readonly DynamicSubOption _options;
private readonly IMqttClientEventHandler _mqttClientEventHandler;
private List<ClientTopic> clientTopics;
private IEnumerable<ClientTopic> _clientTopics;
public DynamicSubManagerService(IMqttClientCreate mqttClientCreate, IMqttClientEventHandler mqttClientEventHandler, IOptions<DynamicSubOption> options)
{
_MqttClientCreate = mqttClientCreate;
_mqttClientEventHandler = mqttClientEventHandler;
_mqttClientEventHandler.SetTopic(out clientTopics);
_mqttClientEventHandler.SetTopic(out _clientTopics);
_options = options.Value;
if (HeartBeatList == null)
{
Expand Down Expand Up @@ -55,14 +55,14 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
if (!value.Online)
{
await Subscribe(clientTopics.Where(x => x.DeviceNo == key).Select(s => s.TopicList).First(), stoppingToken);
await Subscribe(_clientTopics.Where(x => x.DeviceNo == key).Select(s => s.TopicList).First(), stoppingToken);
}
HeartBeatList[key].Online = true;
}
else
{
HeartBeatList[key].Online = false;
await UnSubscribe(clientTopics.Where(x => x.DeviceNo == key).Select(s => s.TopicList).First(), stoppingToken);
await UnSubscribe(_clientTopics.Where(x => x.DeviceNo == key).Select(s => s.TopicList).First(), stoppingToken);
HeartBeatList.Remove(key);
i--;
}
Expand Down
2 changes: 1 addition & 1 deletion MqttNetDI.Client/HeartBeat/IDynamicSubManagerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public interface IDynamicSubManagerService
/// </summary>
Dictionary<string, ClientState> HeartBeatList { get; set; }

List<ClientTopic> ClientTopics { get; set; }
IEnumerable<ClientTopic> ClientTopics { get; }
}
}
1 change: 0 additions & 1 deletion MqttNetDI.Client/MqttClientCreate.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.Extensions.Options;
using MQTTnet;
using MQTTnet.Client;
using MQTTnet.Client.Options;
using System;
using System.Collections.Generic;
using System.Text;
Expand Down

0 comments on commit b660dd1

Please sign in to comment.