修改代码

This commit is contained in:
cli 2024-10-30 18:01:33 +08:00
parent c0716d9667
commit 274b1a7a83
3 changed files with 6 additions and 14 deletions

View File

@ -17,14 +17,10 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddTcpService(config =>
{
config.SetListenIPHosts(int.Parse(configuration["TCP:ClientPort"] ?? "10500"))
.ConfigureContainer(a => //容器的配置顺序应该在最前面
{
a.AddConsoleLogger();
})
.ConfigurePlugins(a =>
{
a.Add<TcpClosePlugin>();
a.Add<TcpServiceReceivedPlugin>();
a.Add<TcpServicePlugin>();
a.Add<BusService>();
});
});
@ -40,13 +36,9 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddUdpSession(config =>
{
config.SetBindIPHost(int.Parse(configuration["UDP:ClientPort"] ?? "10500"))
.ConfigureContainer(a => //容器的配置顺序应该在最前面
{
//a.AddConsoleLogger();
})
.ConfigurePlugins(a =>
{
a.Add<UdpServiceReceivedPlugin>();
a.Add<UdpServicePlugin>();
a.Add<BusService>();
})
.UseBroadcast()

View File

@ -9,15 +9,15 @@ using JiShe.CollectBus.MongoDB;
namespace JiShe.CollectBus.Core.Plugins
{
public partial class TcpServiceReceivedPlugin : PluginBase
public partial class TcpServicePlugin : PluginBase
{
private readonly INSender _nSender;
private readonly ILogger<TcpServiceReceivedPlugin> _logger;
private readonly ILogger<TcpServicePlugin> _logger;
public readonly IMongoRepository<MessageReceivedHeartbeatEvent> _mongoHeartbeatRepository;
public readonly IMongoRepository<MessageReceivedLoginEvent> _mongoLoginRepository;
public TcpServiceReceivedPlugin(INSender nSender, ILogger<TcpServiceReceivedPlugin> logger,IMongoRepository<MessageReceivedHeartbeatEvent> mongoHeartbeatRepository, IMongoRepository<MessageReceivedLoginEvent> mongoLoginRepository)
public TcpServicePlugin(INSender nSender, ILogger<TcpServicePlugin> logger,IMongoRepository<MessageReceivedHeartbeatEvent> mongoHeartbeatRepository, IMongoRepository<MessageReceivedLoginEvent> mongoLoginRepository)
{
_nSender = nSender;
_logger = logger;

View File

@ -4,7 +4,7 @@ using TouchSocket.Sockets;
namespace JiShe.CollectBus.Core.Plugins
{
public partial class UdpServiceReceivedPlugin : PluginBase
public partial class UdpServicePlugin : PluginBase
{
[GeneratorPlugin(typeof(IUdpReceivedPlugin))]
public async Task OnUdpReceived(IUdpSessionBase client, UdpReceivedDataEventArgs e)