标签:byte match dma protect err return cte end protected
public class MyRequestInfo : IRequestInfo
{
public string Key { get; set; }
public byte[] Body { get; set; }
public MyRequestInfo(byte[] readBuffer)
{
Body = readBuffer;
}
}
class MyReceiveFilter : BeginEndMarkReceiveFilter<MyRequestInfo>
{
//开始和结束标记也可以是两个或两个以上的字节
private readonly static byte[] BeginMark = new byte[] { (byte)‘<‘ };
private readonly static byte[] EndMark = new byte[] { (byte)‘>‘ };
public MyReceiveFilter()
: base(BeginMark, EndMark) //传入开始标记和结束标记
{
}
protected override MyRequestInfo ProcessMatchedRequest(byte[] readBuffer, int offset, int length)
{
//TODO: 通过解析到的数据来构造请求实例,并返回
return new MyRequestInfo(readBuffer);
}
}
public class MyAppSession : AppSession<MyAppSession, MyRequestInfo>
{
}
public class MyAppServer : AppServer<MyAppSession, MyRequestInfo>
{
public MyAppServer()
: base(new DefaultReceiveFilterFactory<MyReceiveFilter, MyRequestInfo>()) //使用默认的接受过滤器工厂 (DefaultReceiveFilterFactory)
{
}
}
标签:byte match dma protect err return cte end protected
原文地址:https://www.cnblogs.com/ljsoftware/p/9050328.html