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.

69 lines
1.9 KiB

using CoreAgent.WebSocketTransport.Models;
namespace CoreAgent.WebSocketTransport.Interfaces;
/// <summary>
/// 消息通道管理器接口
/// 单一职责:管理所有消息通道
/// </summary>
public interface IMessageChannelManager : IDisposable
{
/// <summary>
/// 获取发送消息通道
/// </summary>
IMessageChannel<ProtocolMessage> SendChannel { get; }
/// <summary>
/// 获取接收消息通道
/// </summary>
IMessageChannel<object> ReceiveChannel { get; }
/// <summary>
/// 获取优先级消息通道(用于心跳等)
/// </summary>
IMessageChannel<HeartbeatMessage> PriorityChannel { get; }
/// <summary>
/// 获取通道状态信息
/// </summary>
/// <returns>通道状态信息</returns>
ChannelStatusInfo GetStatusInfo();
/// <summary>
/// 创建所有通道(如果已存在则跳过)
/// </summary>
void CreateChannels();
/// <summary>
/// 清空所有通道中的消息(保持通道可用)
/// </summary>
void ClearAllChannels();
/// <summary>
/// 完成所有通道(标记不再接受新消息,但保持可读)
/// </summary>
void CompleteAllChannels();
/// <summary>
/// 释放所有通道(完全释放资源)
/// </summary>
void ReleaseChannels();
}
/// <summary>
/// 通道状态信息
/// </summary>
public class ChannelStatusInfo
{
public int SendChannelCount { get; set; }
public int ReceiveChannelCount { get; set; }
public int PriorityChannelCount { get; set; }
public int SendChannelCapacity { get; set; }
public int ReceiveChannelCapacity { get; set; }
public int PriorityChannelCapacity { get; set; }
public bool SendChannelCompleted { get; set; }
public bool ReceiveChannelCompleted { get; set; }
public bool PriorityChannelCompleted { get; set; }
}