Files
Ayay/SHH.CameraService/Interceptors/ProtocolContext.cs

37 lines
839 B
C#
Raw Normal View History

namespace SHH.CameraService;
/// <summary>
/// 协议上下文 (用于在拦截器之间传递数据)
/// </summary>
public class ProtocolContext
{
public string Protocol { get; set; }
public byte[] Data { get; set; }
/// <summary>
/// 是否拦截/终止 (设为 true 则不再继续传递)
/// </summary>
public bool IsBlocked { get; set; } = false;
public ProtocolContext(string protocol, byte[] data)
{
Protocol = protocol;
Data = data;
}
}
/// <summary>
/// 拦截器接口
/// </summary>
public interface IProtocolInterceptor
{
/// <summary>
/// 发送前触发 (Outbound)
/// </summary>
Task OnSendingAsync(ProtocolContext context);
/// <summary>
/// 接收后触发 (Inbound)
/// </summary>
Task OnReceivedAsync(ProtocolContext context);
}