一款简单易用的基础网络通讯组件库。

TLVDataFrame 类

TLVDataFrame

Definition

命名空间: TouchSocket.Sockets
程序集: TouchSocketPro (在 TouchSocketPro.dll 中) 版本:3.0.0+ccaf96084d09f972257496d1dd63b8ba3c1e44f0
C#
public class TLVDataFrame : IFixedHeaderRequestInfo, 
	IRequestInfo, ITLVDataFrame
Inheritance
Object    TLVDataFrame
Implements
IFixedHeaderRequestInfo, IRequestInfo, ITLVDataFrame

构造函数

TLVDataFrame 初始化一个Ushort的TLVRequestInfo对象。
TLVDataFrame(UInt16) 初始化一个TLVRequestInfo对象。
TLVDataFrame(UInt16, Byte) 初始化一个TLVRequestInfo对象。

属性

LengthValue的有效长度
Tag Tag标识
Value 有效载荷值

方法

AppendValue(Byte) 追加Value。
AppendValue(Byte, Int32, Int32) 追加Value。
Build 构建数据
ClearValue 清除所有Value的值
EqualsDetermines whether the specified object is equal to the current object.
(继承自 Object。)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(继承自 Object。)
GetHashCodeServes as the default hash function.
(继承自 Object。)
GetTypeGets the Type of the current instance.
(继承自 Object。)
MemberwiseCloneCreates a shallow copy of the current Object.
(继承自 Object。)
ToStringReturns a string that represents the current object.
(继承自 Object。)

字段

CloseTag Close
Ping Ping数据。Tag=0。
PingTag Ping
Pong Pong数据。Tag=1。
PongTag Pong

扩展方法

BuildAsBytes 构建为对应字节组
(由 TLVDataFrameExtensions 定义。)
GetValueString 获取utf-8编码的由Value转义的字符串。
(由 TLVDataFrameExtensions 定义。)
Map
(由 Mapper 定义。)
Map
(由 Mapper 定义。)
MapTTarget
(由 Mapper 定义。)
ToJsonString 转换为Json
(由 SerializeConvert 定义。)

显式接口实现

IFixedHeaderRequestInfoBodyLength 数据体长度
IFixedHeaderRequestInfoOnParsingBody 当收到数据,由框架封送有效载荷数据。

如果返回false,意味着放弃本次解析的所有数据,包括已经解析完成的Header

IFixedHeaderRequestInfoOnParsingHeader 当收到数据,由框架封送固定协议头。

您需要在此函数中,解析自己的固定包头,并且对BodyLength赋值后续数据的长度,然后返回True。

如果返回false,则意味着放弃本次解析

参见