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.
26 lines
1.1 KiB
26 lines
1.1 KiB
namespace CoreAgent.WebSocketTransport.Middleware;
|
|
|
|
/// <summary>
|
|
/// WebSocket 消息处理中间件接口
|
|
/// 支持多种处理逻辑(日志、压缩、条件跳过、缓存、加密),增强扩展性和可维护性
|
|
/// </summary>
|
|
public interface IMessageMiddleware
|
|
{
|
|
/// <summary>
|
|
/// 处理发送消息,支持泛型
|
|
/// </summary>
|
|
/// <typeparam name="T">消息类型</typeparam>
|
|
/// <param name="message">要处理的消息</param>
|
|
/// <param name="cancellationToken">取消令牌</param>
|
|
/// <returns>处理后的消息,返回 null 表示跳过后续处理</returns>
|
|
Task<T?> ProcessSendAsync<T>(T message, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// 处理接收消息,支持泛型
|
|
/// </summary>
|
|
/// <typeparam name="T">消息类型</typeparam>
|
|
/// <param name="message">要处理的消息</param>
|
|
/// <param name="cancellationToken">取消令牌</param>
|
|
/// <returns>处理后的消息,返回 null 表示跳过后续处理</returns>
|
|
Task<T?> ProcessReceiveAsync<T>(T message, CancellationToken cancellationToken = default);
|
|
}
|