示例#1
0
        public OpaqueEndpointI(short type, Ice.InputStream s)
        {
            _type        = type;
            _rawEncoding = s.Encoding;
            int sz = s.GetEncapsulationSize();

            _rawBytes = new byte[sz];
            s.ReadBlob(_rawBytes);
        }
示例#2
0
 public OpaqueEndpointI(short type, Ice.InputStream s)
 {
     _type        = type;
     _rawEncoding = s.Encoding;
     _rawBytes    = s.ReadBlob(s.GetEncapsulationSize());
 }
示例#3
0
        private async ValueTask InvokeAllAsync(Ice.OutputStream os, int requestId)
        {
            // The object adapter DirectCount was incremented by the caller and we are responsible to decrement it
            // upon completion.

            Ice.Instrumentation.IDispatchObserver?dispatchObserver = null;
            try
            {
                if (_traceLevels.Protocol >= 1)
                {
                    FillInValue(os, 10, os.Size);
                    if (requestId > 0)
                    {
                        FillInValue(os, Protocol.headerSize, requestId);
                    }
                    TraceUtil.TraceSend(os, _logger, _traceLevels);
                }

                var requestFrame = new Ice.InputStream(os.Communicator, os.Encoding, os.GetBuffer(), false);
                requestFrame.Pos = Protocol.requestHdr.Length;

                int start   = requestFrame.Pos;
                var current = Protocol.CreateCurrent(requestId, requestFrame, _adapter);

                // Then notify and set dispatch observer, if any.
                Ice.Instrumentation.ICommunicatorObserver?communicatorObserver = _adapter.Communicator.Observer;
                if (communicatorObserver != null)
                {
                    int encapsSize = requestFrame.GetEncapsulationSize();

                    dispatchObserver = communicatorObserver.GetDispatchObserver(current,
                                                                                requestFrame.Pos - start + encapsSize);
                    dispatchObserver?.Attach();
                }

                bool amd = true;
                try
                {
                    Ice.IObject?servant = current.Adapter.Find(current.Id, current.Facet);

                    if (servant == null)
                    {
                        amd = false;
                        throw new Ice.ObjectNotExistException(current.Id, current.Facet, current.Operation);
                    }

                    ValueTask <Ice.OutputStream> vt = servant.DispatchAsync(requestFrame, current);
                    amd = !vt.IsCompleted;
                    if (requestId != 0)
                    {
                        var responseFrame = await vt.ConfigureAwait(false);

                        dispatchObserver?.Reply(responseFrame.Size - Protocol.headerSize - 4);
                        SendResponse(requestId, responseFrame, amd);
                    }
                }
                catch (Ice.SystemException ex)
                {
                    Incoming.ReportException(ex, dispatchObserver, current);
                    // Forward the exception to the caller without marshaling
                    HandleException(requestId, ex, amd);
                }
                catch (System.Exception ex)
                {
                    Incoming.ReportException(ex, dispatchObserver, current);
                    if (requestId != 0)
                    {
                        // For now, marshal it
                        // TODO: revisit during exception refactoring.
                        var responseFrame = Protocol.CreateFailureResponseFrame(ex, current);
                        dispatchObserver?.Reply(responseFrame.Size - Protocol.headerSize - 4);
                        SendResponse(requestId, responseFrame, amd);
                    }
                }
            }
            catch (Ice.LocalException ex)
            {
                HandleException(requestId, ex, false);
            }
            finally
            {
                dispatchObserver?.Detach();
                _adapter.DecDirectCount();
            }
        }