using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MECF.Framework.Common.Net { /// /// 本系统的消息类,包含了各种解析规则,数据信息提取规则 /// public interface INetMessage { /// /// 消息头的指令长度 /// int ProtocolHeadBytesLength { get; } /// /// 手动设置消息头指令长度 /// void SetProtocolHeadBytesLength(); /// /// 从当前的头子节文件中提取出接下来需要接收的数据长度 /// /// 返回接下来的数据内容长度 int GetContentLengthByHeadBytes(); /// /// 检查头子节的合法性 /// /// 特殊的令牌,有些特殊消息的验证 /// 是否成功的结果 bool CheckHeadBytesLegal(); /// /// 检查数据合法性 /// /// bool CheckDataLegal(); /// /// 确认返回结果 /// /// bool ConfirmResponseResult(); /// /// 获取头子节里的消息标识 /// /// 消息标识 int GetHeadBytesIdentity(); /// /// 错误代码 /// int ErrorCode { get; set; } /// /// 错误信息 /// string ErrorMsg { get; set; } /// /// 消息头字节 /// byte[] HeadBytes { get; set; } /// /// 消息内容字节 /// byte[] ContentBytes { get; set; } /// /// 发送的字节信息 /// byte[] SendBytes { get; set; } /// /// 编码 /// /// /// byte[] Code(T data); /// /// 解码 /// /// /// T Decode(); } }