Files
TouchSocket/examples/Adapter简单示例/AdapterConsoleApp/MyBigFixedHeaderCustomDataHandlingAdapter.cs
若汝棋茗 e4819ff3ca 更新引用
2022-08-01 21:44:07 +08:00

50 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using TouchSocket.Sockets;
namespace AdapterConsoleApp
{
/// <summary>
/// 模板解析“大数据固定包头”数据适配器
/// </summary>
internal class MyBigFixedHeaderCustomDataHandlingAdapter : CustomBigFixedHeaderDataHandlingAdapter<MyBigFixedHeaderRequestInfo>
{
public override int HeaderLength => throw new NotImplementedException();
public override bool CanSendRequestInfo => false;
protected override MyBigFixedHeaderRequestInfo GetInstance()
{
return new MyBigFixedHeaderRequestInfo();
}
protected override void PreviewSend(IRequestInfo requestInfo, bool isAsync)
{
throw new NotImplementedException();
}
}
/// <summary>
/// 下列吗,没有实现逻辑,仅解释思路。
/// </summary>
internal class MyBigFixedHeaderRequestInfo : IBigFixedHeaderRequestInfo
{
public long BodyLength => throw new NotImplementedException();
public void OnAppendBody(byte[] buffer, int offset, int length)
{
//在这里会一直追加数据体,用户自行实现数据的保存。
}
public bool OnFinished()
{
//触发该方法时说明数据体接收完毕返回true时会触发Receive相关事件否则不会。
return true;
}
public bool OnParsingHeader(byte[] header)
{
//解析头部
return true;
}
}
}