Ejemplo n.º 1
0
        public void SerializeLocal(BinaryWriter writer)
        {
            //Check in sequence of headers..
            FlagsByte bFlags = new FlagsByte();

            if (IsUserMsg)
            {
                bFlags.SetOn(FlagsByte.Flag.TRANS);
            }

            object tmpHdr;

            tmpHdr = (Header)headers[(object)(HeaderType.REQUEST_COORELATOR)];
            if (tmpHdr != null)
            {
                RequestCorrelator.HDR corHdr = (RequestCorrelator.HDR)tmpHdr;
                corHdr.SerializeLocal(writer);
                bFlags.SetOn(FlagsByte.Flag.COR);
            }

            tmpHdr = (Header)headers[(object)(HeaderType.TOTAL)];
            if (tmpHdr != null)
            {
                TOTAL.HDR totalHdr = (TOTAL.HDR)tmpHdr;
                totalHdr.SerializeLocal(writer);
                bFlags.SetOn(FlagsByte.Flag.TOTAL);
            }

            tmpHdr = (Header)headers[(object)(HeaderType.TCP)];
            if (tmpHdr != null)
            {
                TcpHeader tcpHdr = (TcpHeader)tmpHdr;
                tcpHdr.SerializeLocal(writer);
                bFlags.SetOn(FlagsByte.Flag.TCP);
            }

            writer.Write(Convert.ToInt16(prio));
            writer.Write(handledAsynchronously);
            writer.Write(arrivalTime.Ticks);
            writer.Write(sendTime.Ticks);
            writer.Write(responseExpected);
            writer.Write(_type);
            if (stream != null)
            {
                writer.Write(length);
                writer.Write(((MemoryStream)stream).GetBuffer(), 0, length);
            }
            else
            {
                int length = buf.Length;
                writer.Write(length);
                writer.Write(buf);
            }
            long curPos = writer.BaseStream.Position;

            writer.BaseStream.Position = 8;             //afte 4 bytes of total size and 4 bytes of message size ..here comes the flag.
            writer.Write(bFlags.DataByte);
            writer.BaseStream.Position = curPos;
        }
Ejemplo n.º 2
0
 protected override void ResetObject(object obj)
 {
     TOTAL.HDR hdr = obj as TOTAL.HDR;
     if (hdr != null)
     {
         hdr.Reset();
     }
 }
Ejemplo n.º 3
0
        public void DeserializeLocal(BinaryReader reader)
        {
            isUserMsg = true;
            reader.BaseStream.Position = 0;
            byte      flags  = reader.ReadByte();
            FlagsByte bFlags = new FlagsByte();

            bFlags.DataByte = flags;
            //Headers are in sequence 1. COR  2. TOTAL 3. TCP
            headers = new Hashtable();
            if (bFlags.AnyOn(FlagsByte.Flag.COR))
            {
                RequestCorrelator.HDR corHdr = new RequestCorrelator.HDR();
                corHdr.DeserializeLocal(reader);
                headers.Add(HeaderType.REQUEST_COORELATOR, corHdr);
            }

            if (bFlags.AnyOn(FlagsByte.Flag.TOTAL))
            {
                TOTAL.HDR totalHdr = new TOTAL.HDR();
                totalHdr.DeserializeLocal(reader);
                headers.Add(HeaderType.TOTAL, totalHdr);
            }

            if (bFlags.AnyOn(FlagsByte.Flag.TCP))
            {
                TcpHeader tcpHdr = new TcpHeader();
                tcpHdr.DeserializeLocal(reader);
                headers.Add(HeaderType.TCP, tcpHdr);
            }

            prio = (Priority)Enum.ToObject(typeof(Priority), reader.ReadInt16());
            handledAsynchronously = reader.ReadBoolean();
            long ticks = reader.ReadInt64();

            arrivalTime      = new DateTime(ticks);
            ticks            = reader.ReadInt64();
            sendTime         = new DateTime(ticks);
            responseExpected = reader.ReadBoolean();
            _type            = reader.ReadByte();

            length = reader.ReadInt32();
            buf    = (byte[])reader.ReadBytes(length);
        }