mh_sms/APT.MicroApi/APT.OP.WebApi/Utils/WebSokectHelper.cs
2024-04-12 16:50:28 +08:00

41 lines
1.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}
}
}