2025-12-20 13:23:44 +08:00
|
|
|
|
|
|
|
|
|
|
using DOAN.ServiceCore.MyMatchPush;
|
|
|
|
|
|
using Infrastructure;
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ZR.Admin.WebApi.background
|
|
|
|
|
|
{
|
|
|
|
|
|
public class SocketBackgroundService : BackgroundService
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly SocketGatewayServer _socketGateway;
|
|
|
|
|
|
private readonly ILogger<SocketBackgroundService> _logger;
|
|
|
|
|
|
|
|
|
|
|
|
public SocketBackgroundService(SocketGatewayServer socketGateway, ILogger<SocketBackgroundService> logger)
|
|
|
|
|
|
{
|
|
|
|
|
|
_socketGateway = socketGateway;
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// 等待服务完全启动
|
|
|
|
|
|
await Task.Delay(1000, stoppingToken);
|
|
|
|
|
|
|
|
|
|
|
|
// 测试Socket推送功能
|
2025-12-23 08:59:30 +08:00
|
|
|
|
//var result = Watchup.StartPush("测试Socket推送功能", _socketGateway);
|
|
|
|
|
|
//_logger.LogInformation($"Socket推送测试结果: {result}");
|
2025-12-20 13:23:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger.LogError(ex, "Socket推送测试失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|