示例#1
0
        public Ice.OutputStream writeParamEncaps(byte[] v, bool ok)
        {
            if (!ok && _observer != null)
            {
                _observer.userException();
            }

            if (_response)
            {
                var os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                os.writeBlob(Protocol.replyHdr);
                os.writeInt(_current.requestId);
                os.writeByte(ok ? ReplyStatus.replyOK : ReplyStatus.replyUserException);
                if (v == null || v.Length == 0)
                {
                    os.writeEmptyEncapsulation(_current.encoding);
                }
                else
                {
                    os.writeEncapsulation(v);
                }
                return(os);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
文件: Incoming.cs 项目: motuii/ice
        public static Ice.OutputStream createResponseOutputStream(Ice.Current current)
        {
            var os = new Ice.OutputStream(current.adapter.GetCommunicator(), Ice.Util.currentProtocolEncoding);

            os.writeBlob(Protocol.replyHdr);
            os.writeInt(current.requestId);
            os.writeByte(ReplyStatus.replyOK);
            return(os);
        }
示例#3
0
        public Ice.OutputStream startWriteParams()
        {
            if (!_response)
            {
                throw new Ice.MarshalException("can't marshal out parameters for oneway dispatch");
            }

            var os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);

            os.writeBlob(Protocol.replyHdr);
            os.writeInt(_current.requestId);
            os.writeByte(ReplyStatus.replyOK);
            os.startEncapsulation(_current.encoding, _format);
            return(os);
        }
示例#4
0
 public Ice.OutputStream writeEmptyParams()
 {
     if (_response)
     {
         var os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
         os.writeBlob(Protocol.replyHdr);
         os.writeInt(_current.requestId);
         os.writeByte(ReplyStatus.replyOK);
         os.writeEmptyEncapsulation(_current.encoding);
         return(os);
     }
     else
     {
         return(null);
     }
 }
示例#5
0
        public BatchRequestQueue(Instance instance, bool datagram)
        {
            Ice.InitializationData initData = instance.initializationData();
            _interceptor      = initData.batchRequestInterceptor;
            _batchStreamInUse = false;
            _batchRequestNum  = 0;
            _batchStream      = new Ice.OutputStream(instance, Ice.Util.currentProtocolEncoding);
            _batchStream.writeBlob(Protocol.requestBatchHdr);
            _batchMarker = _batchStream.size();
            _request     = new BatchRequestI(this);

            _maxSize = instance.batchAutoFlushSize();
            if (_maxSize > 0 && datagram)
            {
                int udpSndSize = initData.properties.getPropertyAsIntWithDefault("Ice.UDP.SndSize",
                                                                                 65535 - _udpOverhead);
                if (udpSndSize < _maxSize)
                {
                    _maxSize = udpSndSize;
                }
            }
        }
示例#6
0
 //
 // Marshal the endpoint
 //
 public override void streamWrite(Ice.OutputStream s)
 {
     s.startEncapsulation(_rawEncoding, Ice.FormatType.DefaultFormat);
     s.writeBlob(_rawBytes);
     s.endEncapsulation();
 }
示例#7
0
        private void handleException(Exception exc, bool amd)
        {
            Debug.Assert(_responseHandler != null);

            if (exc is Ice.SystemException)
            {
                if (_responseHandler.systemException(_current.requestId, (Ice.SystemException)exc, amd))
                {
                    return;
                }
            }

            try
            {
                throw exc;
            }
            catch (Ice.RequestFailedException ex)
            {
                if (ex.id == null || ex.id.name == null || ex.id.name.Length == 0)
                {
                    ex.id = _current.id;
                }

                if (ex.facet == null || ex.facet.Length == 0)
                {
                    ex.facet = _current.facet;
                }

                if (ex.operation == null || ex.operation.Length == 0)
                {
                    ex.operation = _current.operation;
                }

                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.ice_id());
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    if (ex is Ice.ObjectNotExistException)
                    {
                        _os.writeByte(ReplyStatus.replyObjectNotExist);
                    }
                    else if (ex is Ice.FacetNotExistException)
                    {
                        _os.writeByte(ReplyStatus.replyFacetNotExist);
                    }
                    else if (ex is Ice.OperationNotExistException)
                    {
                        _os.writeByte(ReplyStatus.replyOperationNotExist);
                    }
                    else
                    {
                        Debug.Assert(false);
                    }
                    ex.id.ice_writeMembers(_os);

                    //
                    // For compatibility with the old FacetPath.
                    //
                    if (ex.facet == null || ex.facet.Length == 0)
                    {
                        _os.writeStringSeq(null);
                    }
                    else
                    {
                        string[] facetPath2 = { ex.facet };
                        _os.writeStringSeq(facetPath2);
                    }

                    _os.writeString(ex.operation);

                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Ice.UnknownLocalException ex)
            {
                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.ice_id());
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUnknownLocalException);
                    _os.writeString(ex.unknown);
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Ice.UnknownUserException ex)
            {
                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.ice_id());
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUnknownUserException);
                    _os.writeString(ex.unknown);
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    Debug.Assert(_responseHandler != null && _current != null);
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Ice.UnknownException ex)
            {
                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.ice_id());
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUnknownException);
                    _os.writeString(ex.unknown);
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Ice.UserException ex)
            {
                if (_observer != null)
                {
                    _observer.userException();
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUserException);
                    _os.startEncapsulation(_current.encoding, _format);
                    _os.writeException(ex);
                    _os.endEncapsulation();
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, false);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Ice.Exception ex)
            {
                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.ice_id());
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUnknownLocalException);
                    _os.writeString(ex.ice_id() + "\n" + ex.StackTrace);
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Exception ex)
            {
                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.GetType().FullName);
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUnknownException);
                    _os.writeString(ex.ToString());
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }

            if (_observer != null)
            {
                _observer.detach();
                _observer = null;
            }
            _responseHandler = null;
        }