Пример #1
0
        /// <summary>
        /// Reads the chunk from a byte array.
        /// </summary>
        /// <param name="buffer">The byte array.</param>
        /// <param name="offset">The offset at which to start reading the chunk.</param>
        /// <param name="length">The number of bytes that make up the chunk..</param>
        /// <returns>The number of bytes read.</returns>
        protected override int FromBuffer(byte[] buffer, int offset, int length)
        {
            int start = offset;

            this.InitiateTag = NetworkHelpers.ToUInt32(buffer, offset);
            offset          += 4;
            this.AdvertisedReceiverWindowCredit = NetworkHelpers.ToUInt32(buffer, offset);
            offset += 4;
            this.OutboundStreams = NetworkHelpers.ToUInt16(buffer, offset);
            offset += 2;
            this.InboundStreams = NetworkHelpers.ToUInt16(buffer, offset);
            offset         += 2;
            this.InitialTSN = NetworkHelpers.ToUInt32(buffer, offset);
            offset         += 4;

            while (offset < length)
            {
                if (this.Parameters == null)
                {
                    this.Parameters = new List <ChunkParameter>();
                }

                ChunkParameter parm = new ChunkParameter();
                offset += parm.FromArray(buffer, offset);
                this.Parameters.Add(parm);
            }

            return(offset - start);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        public static ChunkParameter Create(byte[] buffer, int offset)
        {
            ChunkParameter chunk = new ChunkParameter();

            chunk.FromArray(buffer, offset);

            return(chunk);
        }
Пример #3
0
        /// <summary>
        /// Adds a chunk parameter.
        /// </summary>
        /// <param name="parameter">The chunk parameter.</param>
        public void AddParameter(ChunkParameter parameter)
        {
            if (this.Parameters == null)
            {
                this.Parameters = new List <ChunkParameter>();
            }

            this.Parameters.Add(parameter);
        }