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); } }
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); }
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); }
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); } }
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; } } }
// // Marshal the endpoint // public override void streamWrite(Ice.OutputStream s) { s.startEncapsulation(_rawEncoding, Ice.FormatType.DefaultFormat); s.writeBlob(_rawBytes); s.endEncapsulation(); }
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; }