Example #1
0
        /// <summary>Creates a new OutgoingRequestFrame.</summary>
        /// <param name="communicator">The communicator to use when initializing the stream.</param>
        /// <param name="data">The frame data as an array segment.</param>
        public IncomingRequestFrame(Communicator communicator, ArraySegment <byte> data)
        {
            _communicator = communicator;
            Data          = data;
            var istr = new InputStream(communicator, data);

            Identity = new Identity(istr);

            // For compatibility with the old FacetPath.
            string[] facetPath = istr.ReadStringArray();
            if (facetPath.Length > 1)
            {
                throw new InvalidDataException($"invalid facet path length: {facetPath.Length}");
            }
            Facet        = facetPath.Length == 0 ? "" : facetPath[0];
            Operation    = istr.ReadString();
            IsIdempotent = istr.ReadOperationMode() != OperationMode.Normal;
            Context      = istr.ReadContext();
            Payload      = Data.Slice(istr.Pos);
            (Encoding encoding, int size) = istr.ReadEncapsulationHeader();
            if (size != Payload.Count)
            {
                throw new InvalidDataException($"invalid encapsulation size: {size}");
            }
            Encoding = encoding;
        }
Example #2
0
        /// <summary>Creates a new OutgoingRequestFrame.</summary>
        /// <param name="communicator">The communicator to use when initializing the stream.</param>
        /// <param name="data">The frame data as an array segment.</param>
        public IncomingRequestFrame(Communicator communicator, ArraySegment <byte> data)
        {
            _communicator = communicator;
            Data          = data;
            var istr = new InputStream(communicator, data);

            Identity     = new Identity(istr);
            Facet        = istr.ReadFacet();
            Operation    = istr.ReadString();
            IsIdempotent = istr.ReadOperationMode() != OperationMode.Normal;
            Context      = istr.ReadContext();
            Payload      = Data.Slice(istr.Pos);
            (Encoding encoding, int size) = istr.ReadEncapsulationHeader();
            if (size != Payload.Count)
            {
                throw new InvalidDataException($"invalid encapsulation size: {size}");
            }
            Encoding = encoding;
        }