接收过滤器工厂(ReceiveFilterFactory)用于为每个会话创建接收过滤器. 定义一个过滤器工厂(ReceiveFilterFactory)类型, 你必须实现接口 IReceiveFilterFactory. 类型参数 "TRequestInfo" 是你要在整个程序中使用的请求类型
/// <summary>
/// Receive filter factory interface
/// </summary>
/// <typeparam name="TRequestInfo">定义的请求类型 </typeparam>
public interface IReceiveFilterFactory<TRequestInfo> : IReceiveFilterFactory
where TRequestInfo : IRequestInfo
{
/// <summary>
/// 创建接收过滤器
/// </summary>
/// <param name="appServer">The app server.</param>
/// <param name="appSession">The app session.</param>
/// <param name="remoteEndPoint">远程端点.</param>
/// <returns>
/// the new created request filer assosiated with this socketSession
///新建的请求过滤器与SocketSession产生关联
/// </returns>
IReceiveFilter<TRequestInfo> CreateFilter(IAppServer appServer, IAppSession appSession, IPEndPoint remoteEndPoint);
}
你也可以直接使用默认的过滤器工厂(ReceiveFilterFactory)
DefaultReceiveFilterFactory<TReceiveFilter, TRequestInfo>
, 当工厂的CreateFilter方法被调用时,它将会调用TReceiveFilter类型的无参构造方法来创建并返回TReceiveFilter.