Ejemplo n.º 1
0
        /**
         * Methods
         */
        /// <summary>
        /// Initializes a new instance of the <see cref="ProtocolDataUnit"/> class.
        /// </summary>
        /// <param name="bhs"></param>
        /// <param name="rawHeaderData"></param>
        /// <param name="rawContentData"></param>
        public ProtocolDataUnit(byte[] rawHeaderData, byte[] rawContentData)
        {
            this.HeaderData = rawHeaderData;

            HandshakeHeader header = new HandshakeHeader();

            header.ReadFrom(rawHeaderData, 0);
            this.Header = header;

            // decompress content data
            if ((header.DataLength > 0) && (header.CompressedLength > 0))
            {
                // put raw data into a stream to decompress
                MemoryStream memoryStream = new MemoryStream(ZStream.UncompressBuffer(rawContentData));
                this.ContentData = Util.ReadFully(memoryStream, header.DataLength);
            }
            else
            {
                this.ContentData = null;
            }
        }