/// <summary> /// 字节解析为命令对象 /// </summary> public void ReadCommandFromBuffer() { Command.command = System.Text.Encoding.ASCII.GetString(m_bufer, 0, RpcEnvironment.GUID_LEN).TrimEnd('\0'); Command.token = System.Text.Encoding.ASCII.GetString(m_bufer, RpcEnvironment.GUID_LEN, RpcEnvironment.GUID_LEN).TrimEnd('\0'); m_postion = RpcEnvironment.GUID_LEN << 1; Read(ref Command.cmdId); Read(ref Command.tryNum); Read(ref Command.cmdState); Read(ref Command.crcCode); if (Command.crcCode != CrcHelper.Crc(m_bufer, RpcEnvironment.NETCOMMAND_BODY_LEN)) { m_error = true; Command.cmdState = RpcEnvironment.NET_COMMAND_STATE_CRC_ERROR; return; } Read(ref Command.dataLen); if (Command.dataLen == 0) { return; } m_start_postion = RpcEnvironment.NETCOMMAND_HEAD_LEN; Begin(); Command.dataTypeId = this.m_type_id; Command.Data = TsonTypeRegister.CreateType(Command.dataTypeId); if (Command.Data == null) { m_error = true; Command.cmdState = RpcEnvironment.NET_COMMAND_STATE_UNKNOW_DATA; return; } Command.Data.Deserialize(this); }
/// <summary> /// 注册类型 /// </summary> public static void ReigsterEntityType() { TsonTypeRegister.RegisteType <StringArgumentData>(StringArgumentData.EntityId, "文本的参数"); }