41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
|
|
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);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|