2024-12-19 16:07:07 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Models;
|
2025-03-14 14:28:04 +08:00
|
|
|
|
using JiShe.CollectBus.IotSystems.MessageReceiveds;
|
2024-12-19 16:07:07 +08:00
|
|
|
|
using JiShe.CollectBus.Protocol.Contracts.Interfaces;
|
|
|
|
|
|
using MassTransit;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
|
|
namespace JiShe.CollectBus.Consumers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class ReceivedLoginConsumer : IConsumer<MessageReceivedLogin>
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ILogger<ReceivedLoginConsumer> _logger;
|
|
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="logger"></param>
|
|
|
|
|
|
/// <param name="serviceProvider"></param>
|
|
|
|
|
|
public ReceivedLoginConsumer(ILogger<ReceivedLoginConsumer> logger, IServiceProvider serviceProvider)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task Consume(ConsumeContext<MessageReceivedLogin> context)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogInformation("登录消费队列开始处理");
|
|
|
|
|
|
var protocolPlugin = _serviceProvider.GetKeyedService<IProtocolPlugin>("Standard");
|
|
|
|
|
|
if (protocolPlugin == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError("【登录消费队列开始处理】协议不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
await protocolPlugin.LoginAsync(context.Message);
|
|
|
|
|
|
_logger.LogInformation("登录消费队列完成处理");
|
|
|
|
|
|
}
|
|
|
|
|
|
await Task.CompletedTask;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|