예제 #1
0
        public void finished(BasicStream istr)
        {
            _m.Lock();
            try
            {
                Debug.Assert(_handler.getReference().getMode() == Reference.Mode.ModeTwoway); // Only for twoways.

                Debug.Assert(_state <= StateInProgress);

                if(_remoteObserver != null)
                {
                    _remoteObserver.reply(istr.size() - Protocol.headerSize - 4);
                    _remoteObserver.detach();
                    _remoteObserver = null;
                }

                if(_is == null)
                {
                    _is = new IceInternal.BasicStream(_handler.getReference().getInstance(), 
                                                      Ice.Util.currentProtocolEncoding);
                }
                _is.swap(istr);
                byte replyStatus = _is.readByte();

                switch(replyStatus)
                {
                    case ReplyStatus.replyOK:
                    {
                        _state = StateOK; // The state must be set last, in case there is an exception.
                        break;
                    }

                    case ReplyStatus.replyUserException:
                    {
                        if(_observer != null)
                        {
                            _observer.userException();
                        }
                        _state = StateUserException; // The state must be set last, in case there is an exception.
                        break;
                    }

                    case ReplyStatus.replyObjectNotExist:
                    case ReplyStatus.replyFacetNotExist:
                    case ReplyStatus.replyOperationNotExist:
                    {
                        Ice.RequestFailedException ex = null;
                        switch(replyStatus)
                        {
                            case ReplyStatus.replyObjectNotExist:
                            {
                                ex = new Ice.ObjectNotExistException();
                                break;
                            }

                            case ReplyStatus.replyFacetNotExist:
                            {
                                ex = new Ice.FacetNotExistException();
                                break;
                            }

                            case ReplyStatus.replyOperationNotExist:
                            {
                                ex = new Ice.OperationNotExistException();
                                break;
                            }

                            default:
                            {
                                Debug.Assert(false);
                                break;
                            }
                        }

                        ex.id = new Ice.Identity();
                        ex.id.read__(_is);

                        //
                        // For compatibility with the old FacetPath.
                        //
                        string[] facetPath = _is.readStringSeq();
                        if(facetPath.Length > 0)
                        {
                            if(facetPath.Length > 1)
                            {
                                throw new Ice.MarshalException();
                            }
                            ex.facet = facetPath[0];
                        }
                        else
                        {
                            ex.facet = "";
                        }

                        ex.operation = _is.readString();
                        _exception = ex;

                        _state = StateLocalException; // The state must be set last, in case there is an exception.
                        break;
                    }

                    case ReplyStatus.replyUnknownException:
                    case ReplyStatus.replyUnknownLocalException:
                    case ReplyStatus.replyUnknownUserException:
                    {
                        Ice.UnknownException ex = null;
                        switch(replyStatus)
                        {
                            case ReplyStatus.replyUnknownException:
                            {
                                ex = new Ice.UnknownException();
                                break;
                            }

                            case ReplyStatus.replyUnknownLocalException:
                            {
                                ex = new Ice.UnknownLocalException();
                                break;
                            }

                            case ReplyStatus.replyUnknownUserException:
                            {
                                ex = new Ice.UnknownUserException();
                                break;
                            }

                            default:
                            {
                                Debug.Assert(false);
                                break;
                            }
                        }

                        ex.unknown = _is.readString();
                        _exception = ex;

                        _state = StateLocalException; // The state must be set last, in case there is an exception.
                        break;
                    }

                    default:
                    {
                        _exception = new Ice.UnknownReplyStatusException();
                        _state = StateLocalException;
                        break;
                    }
                }

                _m.Notify();
            }
            finally
            {
                _m.Unlock();
            }
        }
예제 #2
0
파일: Outgoing.cs 프로젝트: stick/zeroc-ice
        public void finished(BasicStream istr)
        {
            _m.Lock();
            try
            {
                Debug.Assert(_handler.getReference().getMode() == Reference.Mode.ModeTwoway); // Only for twoways.

                Debug.Assert(_state <= StateInProgress);

                if (_remoteObserver != null)
                {
                    _remoteObserver.reply(istr.size() - Protocol.headerSize - 4);
                    _remoteObserver.detach();
                    _remoteObserver = null;
                }

                if (_is == null)
                {
                    _is = new IceInternal.BasicStream(_handler.getReference().getInstance(),
                                                      Ice.Util.currentProtocolEncoding);
                }
                _is.swap(istr);
                byte replyStatus = _is.readByte();

                switch (replyStatus)
                {
                case ReplyStatus.replyOK:
                {
                    _state = StateOK;     // The state must be set last, in case there is an exception.
                    break;
                }

                case ReplyStatus.replyUserException:
                {
                    if (_observer != null)
                    {
                        _observer.userException();
                    }
                    _state = StateUserException;     // The state must be set last, in case there is an exception.
                    break;
                }

                case ReplyStatus.replyObjectNotExist:
                case ReplyStatus.replyFacetNotExist:
                case ReplyStatus.replyOperationNotExist:
                {
                    Ice.RequestFailedException ex = null;
                    switch (replyStatus)
                    {
                    case ReplyStatus.replyObjectNotExist:
                    {
                        ex = new Ice.ObjectNotExistException();
                        break;
                    }

                    case ReplyStatus.replyFacetNotExist:
                    {
                        ex = new Ice.FacetNotExistException();
                        break;
                    }

                    case ReplyStatus.replyOperationNotExist:
                    {
                        ex = new Ice.OperationNotExistException();
                        break;
                    }

                    default:
                    {
                        Debug.Assert(false);
                        break;
                    }
                    }

                    ex.id = new Ice.Identity();
                    ex.id.read__(_is);

                    //
                    // For compatibility with the old FacetPath.
                    //
                    string[] facetPath = _is.readStringSeq();
                    if (facetPath.Length > 0)
                    {
                        if (facetPath.Length > 1)
                        {
                            throw new Ice.MarshalException();
                        }
                        ex.facet = facetPath[0];
                    }
                    else
                    {
                        ex.facet = "";
                    }

                    ex.operation = _is.readString();
                    _exception   = ex;

                    _state = StateLocalException;     // The state must be set last, in case there is an exception.
                    break;
                }

                case ReplyStatus.replyUnknownException:
                case ReplyStatus.replyUnknownLocalException:
                case ReplyStatus.replyUnknownUserException:
                {
                    Ice.UnknownException ex = null;
                    switch (replyStatus)
                    {
                    case ReplyStatus.replyUnknownException:
                    {
                        ex = new Ice.UnknownException();
                        break;
                    }

                    case ReplyStatus.replyUnknownLocalException:
                    {
                        ex = new Ice.UnknownLocalException();
                        break;
                    }

                    case ReplyStatus.replyUnknownUserException:
                    {
                        ex = new Ice.UnknownUserException();
                        break;
                    }

                    default:
                    {
                        Debug.Assert(false);
                        break;
                    }
                    }

                    ex.unknown = _is.readString();
                    _exception = ex;

                    _state = StateLocalException;     // The state must be set last, in case there is an exception.
                    break;
                }

                default:
                {
                    _exception = new Ice.UnknownReplyStatusException();
                    _state     = StateLocalException;
                    break;
                }
                }

                _m.Notify();
            }
            finally
            {
                _m.Unlock();
            }
        }