d_sms_service/APT.MicroApi/APT.PF.WebApi/Utils/WebSokectHelper.cs

41 lines
1.5 KiB
C#
Raw Normal View History

2024-10-28 13:45:58 +08:00
using APT.Infrastructure.Core;
using APT.BaseData.Domain.IServices.EX;
using System;
using APT.BaseData.Domain.IServices.Platform;
using APT.BaseData.Services.Services.EX;
using APT.Infrastructure.Api;
namespace APT.PF.WebApi.Utils
{
public static class WebSokectHelper
{
public static void Init()
{
//var webSocketService = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<IWebSocketService>();
//var versionService = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<IPFLastVersionService>();
var webSocketPort = LibUtils.ToInt(
ConfigurationManager.AppSettings["WebSocketPort"]);
try
{
WebSocketServiceHelper.InitService(webSocketPort,
(clientInfo) =>
{
return WebSocketService.OnOpenWebSocket(clientInfo);
},
(clientInfo, requestInfo) =>
{
return WebSocketService.OnMessageWebSocket(clientInfo, requestInfo);
},
(userId, clientInfo) =>
{
WebSocketService.OnCloseWebSocket(userId, clientInfo);
});
}
catch (Exception ex)
{
LoggerManager.GetLogger("Application").Error("WebSocket初始化错误" + ex.Message);
}
}
}
}