mh_lcmk_sms_service/APT.MicroApi/APT.OP.WebApi/Utils/WebSokectHelper.cs

41 lines
1.4 KiB
C#
Raw Permalink Normal View History

2024-07-12 16:37:09 +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 = ServiceLocator.Instance.GetService<IWebSocketService>();
//var versionService = 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);
}
}
}
}