Esempio n. 1
0
        public override object Read(IProtocolBuffer buffer)
        {
            UInt16         data   = buffer.ReadUInt16();
            IBitCustomType result = (IBitCustomType)Activator.CreateInstance(mType);

            result.Load(data);
            return(result);
        }
Esempio n. 2
0
        public void Load(IProtocolBuffer buffer)
        {
            ushort value = buffer.ReadUInt16();

            CustomHigh    = (CUSTOM_HEIGHT & value) > 0;
            CustomLow     = (CUSTOM_LOW & value) > 0;
            IsPacket      = (IS_PACKET & value) > 0;
            EncryptHigh   = (ENCRYPT_HEIGHT & value) > 0;
            EncryptMiddle = (ENCRYPT_MIDDLE & value) > 0;
            EncryptLow    = (ENCRYPT_LOW & value) > 0;
            BodyLength    = (ushort)(BODY_LENGTH & value);
        }
Esempio n. 3
0
        public void Read(IProtocolBuffer buffer)
        {
            //byte crc = Core.GetCRC(buffer.Array, 1, buffer.Length - 3);
            //CRC = buffer.Array[buffer.Length - 2];
            //if(CRC != crc)
            //	throw new ProtocolProcessError("message check CRC error!");

            buffer.Read();                          //read start      标识位
            ID = buffer.ReadUInt16();               //read id         消息 ID
            Property.Read(buffer);                  //read property   消息体属性
            SIM = buffer.ReadBCD(6);                //read sim        终端手机号
            No  = buffer.ReadUInt16();              //read no 消息流水号
            if (Property.IsPacket)                  //read packet     消息包封装项
            {
                Packet = new PacketInfo();
                Packet.Load(buffer);
            }
            if (Property.BodyLength > 0) //read body      消息体
            {
                IProtocolBuffer bodybuffer = ProtocolBufferPool.Default.Pop();
                try
                {
                    buffer.ReadSubBuffer(bodybuffer, Property.BodyLength);
                    Serializer serializer = SerializerFactory.Defalut.Get(ID);
                    if (serializer != null)
                    {
                        Body = serializer.CreateObject();
                        serializer.Deserialize(Body, bodybuffer);
                    }
                }
                finally
                {
                    ProtocolBufferPool.Default.Push(bodybuffer);
                }
            }
            CRC = buffer.Read();             //read crc  检验码
            buffer.Read();                   //read end  标识位
        }
Esempio n. 4
0
        public void Load(IProtocolBuffer buffer)
        {
            byte crc = Core.GetCRC(buffer.Array, 1, buffer.Length - 3);

            this.CRC = buffer.Array[buffer.Length - 2];
            if (this.CRC != crc)
            {
                throw new ProtocolProcessError("message check CRC error!");
            }
            buffer.Read();                     //read start
            ID = buffer.ReadUInt16();          //read id
            Property.Load(buffer);             //read property
            SIM         = buffer.ReadBCD(6);   //read sim
            BussinessNO = buffer.ReadUInt16(); //read no
            if (Property.IsPacket)             //read packet
            {
                Packet = new PacketInfo();
                Packet.Load(buffer);
            }
            if (Property.BodyLength > 0) //read body
            {
                IProtocolBuffer bodybuffer = ProtocolBufferPool.Default.Pop();
                try
                {
                    buffer.ReadSubBuffer(bodybuffer, Property.BodyLength);
                    Serializer serializer = SerializerFactory.Defalut.Get(ID);
                    Body = serializer.CreateObject();
                    serializer.Deserialize(Body, bodybuffer);
                }
                finally
                {
                    ProtocolBufferPool.Default.Push(bodybuffer);
                }
            }
            this.CRC = buffer.Read(); //read crc
            buffer.Read();            //read end
        }
Esempio n. 5
0
 public override object Read(IProtocolBuffer buffer)
 {
     return(buffer.ReadUInt16());
 }