Пример #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;
        }
Пример #2
0
        internal static Ice.Current CreateCurrent(int requestId, Ice.InputStream requestFrame,
                                                  Ice.ObjectAdapter adapter, Ice.Connection?connection = null)
        {
            var identity = new Ice.Identity(requestFrame);

            // For compatibility with the old FacetPath.
            string[] facetPath = requestFrame.ReadStringArray();
            if (facetPath.Length > 1)
            {
                throw new Ice.MarshalException();
            }
            string facet     = facetPath.Length == 0 ? "" : facetPath[0];
            string operation = requestFrame.ReadString();
            var    mode      = requestFrame.ReadByte();

            if (mode > 2)
            {
                throw new Ice.MarshalException(
                          $"received invalid operation mode `{mode}' with operation `{operation}'");
            }
            bool idempotent = mode > 0;
            var  context    = requestFrame.ReadContext();

            Ice.EncodingVersion encoding = requestFrame.StartEncapsulation();

            return(new Ice.Current(adapter, identity, facet, operation, idempotent, context,
                                   requestId, connection, encoding));
        }
Пример #3
0
        internal Current(int requestId, InputStream request, ObjectAdapter adapter, Ice.Connection?connection = null)
        {
            Adapter = adapter;
            Id      = new Identity(request);

            // For compatibility with the old FacetPath.
            string[] facetPath = request.ReadStringArray();
            if (facetPath.Length > 1)
            {
                throw new MarshalException();
            }
            Facet        = facetPath.Length == 0 ? "" : facetPath[0];
            Operation    = request.ReadString();
            IsIdempotent = request.ReadOperationMode() != OperationMode.Normal;
            Context      = request.ReadContext();
            RequestId    = requestId;
            Connection   = connection;
            Encoding     = request.StartEncapsulation();
        }
Пример #4
0
        private static void PrintIdentityFacetOperation(System.IO.StringWriter s, Ice.InputStream str)
        {
            try
            {
                Ice.ToStringMode toStringMode = str.Communicator.ToStringMode;

                var identity = new Ice.Identity(str);
                s.Write("\nidentity = " + identity.ToString(toStringMode));

                string[] facet = str.ReadStringArray();
                s.Write("\nfacet = ");
                if (facet.Length > 0)
                {
                    s.Write(IceUtilInternal.StringUtil.EscapeString(facet[0], "", toStringMode));
                }

                string operation = str.ReadString();
                s.Write("\noperation = " + operation);
            }
            catch (System.IO.IOException)
            {
                Debug.Assert(false);
            }
        }
Пример #5
0
        internal DispatchException ReadDispatchException()
        {
            var istr     = new InputStream(_communicator, Payload, 1);
            var 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}");
            }
            string facet = facetPath.Length > 0 ? facetPath[0] : "";

            string operation = istr.ReadString();

            if (ReplyStatus == ReplyStatus.OperationNotExistException)
            {
                return(new OperationNotExistException(identity, facet, operation));
            }
            else
            {
                return(new ObjectNotExistException(identity, facet, operation));
            }
        }