コード例 #1
0
ファイル: Proxy.cs プロジェクト: yssource/ice
 /// <summary>Sends a request synchronously.</summary>
 /// <param name="proxy">The proxy for the target Ice object.</param>
 /// <param name="request">The outgoing request frame for this invocation. Usually this request frame should have
 /// been created using the same proxy, however some differences are acceptable, for example proxy can have
 /// different endpoints.</param>
 /// <param name="oneway">When true, the request is sent as a oneway request. When false, it is sent as a
 /// two-way request.</param>
 /// <returns>The response frame.</returns>
 public static IncomingResponseFrame Invoke(this IObjectPrx proxy, OutgoingRequestFrame request,
                                            bool oneway = false)
 {
     try
     {
         return(proxy.IceInvokeAsync(request, oneway, null, CancellationToken.None, true).Result);
     }
     catch (AggregateException ex)
     {
         throw ex.InnerException;
     }
 }
コード例 #2
0
        /// <summary>Sends a request asynchronously.</summary>
        /// <param name="proxy">The proxy for the target Ice object.</param>
        /// <param name="request">The outgoing request frame for this invocation. Usually this request frame should have
        /// been created using the same proxy, however some differences are acceptable, for example proxy can have
        /// different endpoints.</param>
        /// <param name="oneway">When true, the request is sent as a oneway request. When false, it is sent as a
        /// two-way request.</param>
        /// <param name="progress">Sent progress provider.</param>
        /// <param name="cancel">A cancellation token that receives the cancellation requests.</param>
        /// <returns>A task holding the response frame.</returns>
        public static Task <IncomingResponseFrame> InvokeAsync(this IObjectPrx proxy,
                                                               OutgoingRequestFrame request,
                                                               bool oneway = false,
                                                               IProgress <bool>?progress = null,
                                                               CancellationToken cancel  = default)
        {
            var completed = new IObjectPrx.InvokeTaskCompletionCallback(progress, cancel);

            new OutgoingAsync(proxy, completed, request, oneway: oneway).Invoke(request.Operation, request.Context,
                                                                                synchronous: false);
            return(completed.Task);
        }
コード例 #3
0
ファイル: OutgoingRequestFrame.cs プロジェクト: yuwenyong/ice
        /// <summary>Create a new OutgoingRequestFrame.</summary>
        /// <param name="proxy">A proxy to the target Ice object. This method uses the communicator, identity, facet,
        /// encoding and context of this proxy to create the request frame.</param>
        /// <param name="operation">The operation to invoke on the target Ice object.</param>
        /// <param name="idempotent">True when operation is idempotent, otherwise false.</param>
        /// <param name="format">The format type used to marshal classes and exceptions, when this parameter is null
        /// the communicator's default format is used.</param>
        /// <param name="context">An optional explicit context. When non null, it overrides both the context of the
        /// proxy and the communicator's current context (if any).</param>
        /// <param name="value">The parameter to marshal in the frame.</param>
        /// <param name="writer">The delegate into marshal the parameter to the frame.</param>
        /// <returns>A new OutgoingRequestFrame</returns>
        public static OutgoingRequestFrame WithParamList <T>(
            IObjectPrx proxy, string operation, bool idempotent, FormatType?format,
            IReadOnlyDictionary <string, string>?context,
            T value, OutputStreamWriter <T> writer)
        {
            var request = new OutgoingRequestFrame(proxy, operation, idempotent, context);
            var ostr    = new OutputStream(request.Encoding, request.Data, request._payloadStart,
                                           format ?? proxy.Communicator.DefaultFormat);

            writer(ostr, value);
            request.Finish(ostr.Save());
            return(request);
        }
コード例 #4
0
ファイル: Proxy.cs プロジェクト: yssource/ice
        /// <summary>Forwards an incoming request to another Ice object.</summary>
        /// <param name="proxy">The proxy for the target Ice object.</param>
        /// <param name="request">The incoming request frame.</param>
        /// <param name="progress">Sent progress provider.</param>
        /// <param name="cancel">A cancellation token that receives the cancellation requests.</param>
        /// <returns>A task holding the response frame.</returns>
        public static async ValueTask <OutputStream> ForwardAsync(this IObjectPrx proxy,
                                                                  IncomingRequestFrame request,
                                                                  IProgress <bool>?progress = null,
                                                                  CancellationToken cancel  = default)
        {
            var forwardedRequest = new OutgoingRequestFrame(proxy, request.Current.Operation,
                                                            request.Current.IsIdempotent, request.Current.Context, request.TakePayload());

            IncomingResponseFrame response =
                await proxy.InvokeAsync(forwardedRequest, oneway : request.Current.IsOneway, progress, cancel)
                .ConfigureAwait(false);

            return(new OutgoingResponseFrame(request.Current, response.ReplyStatus, response.TakePayload()));
        }
コード例 #5
0
 /// <summary>Sends a request synchronously.</summary>
 /// <param name="proxy">The proxy for the target Ice object.</param>
 /// <param name="request">The outgoing request frame for this invocation. Usually this request frame should have
 /// been created using the same proxy, however some differences are acceptable, for example proxy can have
 /// different endpoints.</param>
 /// <param name="oneway">When true, the request is sent as a oneway request. When false, it is sent as a
 /// two-way request.</param>
 /// <returns>The response frame.</returns>
 public static IncomingResponseFrame Invoke(this IObjectPrx proxy, OutgoingRequestFrame request,
                                            bool oneway = false)
 {
     try
     {
         var completed = new IObjectPrx.InvokeTaskCompletionCallback(null, default);
         new OutgoingAsync(proxy, completed, request, oneway: oneway).Invoke(request.Operation, request.Context,
                                                                             synchronous: true);
         return(completed.Task.Result);
     }
     catch (AggregateException ex)
     {
         Debug.Assert(ex.InnerException != null);
         throw ex.InnerException;
     }
 }
コード例 #6
0
        internal static List <ArraySegment <byte> > GetRequestData(OutgoingRequestFrame frame, int requestId)
        {
            byte[] headerData = new byte[HeaderSize + 4];
            RequestHeader.CopyTo(headerData.AsSpan());

            OutputStream.WriteInt(frame.Size + HeaderSize + 4, headerData.AsSpan(10, 4));
            OutputStream.WriteInt(requestId, headerData.AsSpan(HeaderSize, 4));

            var data = new List <ArraySegment <byte> >()
            {
                headerData
            };

            data.AddRange(frame.Data);
            return(data);
        }
コード例 #7
0
ファイル: Proxy.cs プロジェクト: yssource/ice
 /// <summary>Sends a request asynchronously.</summary>
 /// <param name="proxy">The proxy for the target Ice object.</param>
 /// <param name="request">The outgoing request frame for this invocation. Usually this request frame should have
 /// been created using the same proxy, however some differences are acceptable, for example proxy can have
 /// different endpoints.</param>
 /// <param name="oneway">When true, the request is sent as a oneway request. When false, it is sent as a
 /// two-way request.</param>
 /// <param name="progress">Sent progress provider.</param>
 /// <param name="cancel">A cancellation token that receives the cancellation requests.</param>
 /// <returns>A task holding the response frame.</returns>
 public static Task <IncomingResponseFrame> InvokeAsync(this IObjectPrx proxy,
                                                        OutgoingRequestFrame request,
                                                        bool oneway = false,
                                                        IProgress <bool>?progress = null,
                                                        CancellationToken cancel  = default)
 => proxy.IceInvokeAsync(request, oneway, progress, cancel, false);
コード例 #8
0
 // TODO avoid copy payload (ToArray) creates a copy, that should be possible when
 // the frame has a single segment.
 internal IncomingRequestFrame(Communicator communicator, OutgoingRequestFrame frame)
     : this(communicator, VectoredBufferExtensions.ToArray(frame.Data))
 {
 }
コード例 #9
0
 /// <summary>Sends a request synchronously.</summary>
 /// <param name="proxy">The proxy for the target Ice object.</param>
 /// <param name="request">The outgoing request frame for this invocation. Usually this request frame should have
 /// been created using the same proxy, however some differences are acceptable, for example proxy can have
 /// different endpoints.</param>
 /// <param name="oneway">When true, the request is sent as a oneway request. When false, it is sent as a
 /// two-way request.</param>
 /// <returns>The response frame.</returns>
 public static IncomingResponseFrame Invoke(this IObjectPrx proxy, OutgoingRequestFrame request,
                                            bool oneway = false)
 => proxy.IceInvoke(request, oneway);