You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
using Microsoft.Extensions.Logging;
|
|
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using WebSocket4Net;
|
|
|
|
namespace CoreAgent.ProtocolClient.Managers.WebSocketMgr
|
|
{
|
|
public partial class WebSocketMessageManager
|
|
{
|
|
#region 构造函数
|
|
|
|
public WebSocketMessageManager(string clientName, ILoggerFactory loggerFactory)
|
|
{
|
|
// 参数验证
|
|
_clientName = clientName ?? throw new ArgumentNullException(nameof(clientName));
|
|
var factory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
|
|
|
|
// 创建自己的Logger
|
|
_logger = factory.CreateLogger<WebSocketMessageManager>();
|
|
|
|
// 初始化消息ID管理器 - 使用ILoggerFactory创建正确的logger类型
|
|
var messageIdLogger = factory.CreateLogger<MessageIdManager>();
|
|
_messageIdManager = new MessageIdManager(clientName, messageIdLogger);
|
|
|
|
// 创建消息队列
|
|
_messageFifo = new BlockingCollection<JObject>();
|
|
|
|
_logger.LogInformation($"[{_clientName}] 创建WebSocket消息管理器");
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|