using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MECF.Framework.RT.Core.IoProviders.Common.IMessage { /// /// 异形消息对象,用于异形客户端的注册包接收以及验证使用 /// public class AlienMessage : INetMessage { /// /// 本协议的消息头长度 /// public int ProtocolHeadBytesLength { get { return 5; } } /// /// 头子节信息 /// public byte[] HeadBytes { get; set; } /// /// 内容字节信息 /// public byte[] ContentBytes { get; set; } /// /// 检查接收的数据是否合法 /// /// 令牌 /// 是否合法 public bool CheckHeadBytesLegal(byte[] token) { if (HeadBytes == null) return false; if (HeadBytes[0] == 0x48 && HeadBytes[1] == 0x73 && HeadBytes[2] == 0x6E) { return true; } else { return false; } } /// /// 从头子节信息中解析出接下来需要接收的数据长度 /// /// 接下来的数据长度 public int GetContentLengthByHeadBytes() { return HeadBytes[4]; } /// /// 获取头子节里的特殊标识 /// /// 标识信息 public int GetHeadBytesIdentity() { return 0; } /// /// 发送的字节信息 /// public byte[] SendBytes { get; set; } } }