手表通讯完毕

This commit is contained in:
gcw_MV9p2JJN
2025-12-20 13:23:44 +08:00
parent 16168ed598
commit 3d46c7e7b7
4 changed files with 354 additions and 0 deletions

View File

@@ -0,0 +1,36 @@

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推送功能
var result = Watchup.StartPush("测试Socket推送功能", _socketGateway);
_logger.LogInformation($"Socket推送测试结果: {result}");
}
catch (Exception ex)
{
_logger.LogError(ex, "Socket推送测试失败");
}
}
}
}