Exemplo n.º 1
0
        /// <summary>
        ///     Take a raw message buffer and extract the endpoint name and serialized proto buffer.
        /// </summary>
        /// <param name="messageData"></param>
        public Message(byte[] messageData)
        {
            unsafe
            {
                var segmentReader = new UnsafeBinaryReader(Encoding.UTF8);
                fixed(byte *mData = messageData)
                {
                    var segment = new BufferSegment(mData);

                    segmentReader.SetBuffer(segment.Data, messageData.Length);
                    var length = segmentReader.ReadVariableLengthQuantity();

                    fixed(byte *headerData = segmentReader.ReadBytes(length))
                    {
                        Header = GetHeader(headerData, length);
                    }

                    Payload = segmentReader.ReadBytes(segmentReader.AvailableData());
                }
            }
        }