public override void WriteByte(byte value) { try { if (_data != null) { // If we can fit the data into the first 254 bytes, write it to _data. if (_pos < _data.Length) { _data[_pos++] = value; return; } // Dummy size, until we know how big the stream really is and can patch the size. _stream.WriteSize(255); if (_pos > 0) { // Write the current contents of _data. _stream.WriteByteSpan(_data.AsSpan(0, _pos)); } _data = null; } // Write data passed by caller. _stream.WriteByte(value); _pos += 1; } catch (Exception ex) { throw new IOException("could not write to stream", ex); } }
/// <summary>Creates a new response frame that represents "success" with a void return value. The returned /// frame is complete and no additional data can be included in its payload.</summary> /// <param name="current">The current parameter holds decoded header data and other information about the /// request currently dispatched.</param> /// <returns>An <see cref="Ice.OutputStream"/> that holds the new frame.</returns> public static Ice.OutputStream CreateEmptyResponseFrame(Ice.Current current) { var ostr = new Ice.OutputStream(current.Adapter.Communicator, Ice.Util.CurrentProtocolEncoding); ostr.WriteBlob(Protocol.replyHdr); ostr.WriteInt(current.RequestId); ostr.WriteByte(ReplyStatus.replyOK); ostr.WriteEmptyEncapsulation(current.Encoding); return(ostr); }
/// <summary>Starts a new response frame and the encapsulation in that frame. This frame encodes a "success" /// response.</summary> /// <param name="current">The current parameter holds decoded header data and other information about the /// request currently dispatched.</param> /// <param name="format">The Slice format (Compact or Sliced) used by the encapsulation.</param> /// <returns>An <see cref="Ice.OutputStream"/> that holds the new frame.</returns> public static Ice.OutputStream StartResponseFrame(Ice.Current current, Ice.FormatType?format = null) { var ostr = new Ice.OutputStream(current.Adapter.Communicator, Ice.Util.CurrentProtocolEncoding); ostr.WriteBlob(Protocol.replyHdr); ostr.WriteInt(current.RequestId); ostr.WriteByte(ReplyStatus.replyOK); ostr.StartEncapsulation(current.Encoding, format); return(ostr); }
/// <summary>Starts a new response frame and the encapsulation in that frame. This frame encodes a "failure" /// response.</summary> /// <param name="current">The current parameter holds decoded header data and other information about the /// request currently dispatched.</param> /// <returns>An <see cref="Ice.OutputStream"/> that holds the new frame.</returns> public static Ice.OutputStream StartFailureResponseFrame(Ice.Current current) { var ostr = new Ice.OutputStream(current.Adapter.Communicator, Ice.Util.CurrentProtocolEncoding); ostr.WriteBlob(Protocol.replyHdr); ostr.WriteInt(current.RequestId); ostr.WriteByte(ReplyStatus.replyUserException); // Exceptions are always marshaled in the sliced format: ostr.StartEncapsulation(current.Encoding, FormatType.SlicedFormat); return(ostr); }
///<summary>Creates a response frame that represents "failure" and contains an exception. The returned frame is /// complete and no additional data can be included in its payload.</summary> /// <param name="exception">The exception to marshal into the frame.</param> /// <param name="current">The current parameter holds decoded header data and other information about the /// request currently dispatched.</param> /// <returns>An <see cref="Ice.OutputStream"/> that holds the new frame.</returns> public static Ice.OutputStream CreateFailureResponseFrame(System.Exception exception, Ice.Current current) { var ostr = new Ice.OutputStream(current.Adapter.Communicator, Ice.Util.CurrentProtocolEncoding); ostr.WriteBlob(Protocol.replyHdr); ostr.WriteInt(current.RequestId); try { throw exception; } catch (Ice.RequestFailedException ex) { if (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 (ex is Ice.ObjectNotExistException) { ostr.WriteByte(ReplyStatus.replyObjectNotExist); } else if (ex is Ice.FacetNotExistException) { ostr.WriteByte(ReplyStatus.replyFacetNotExist); } else if (ex is Ice.OperationNotExistException) { ostr.WriteByte(ReplyStatus.replyOperationNotExist); } else { Debug.Assert(false); } ex.Id.IceWrite(ostr); // For compatibility with the old FacetPath. if (ex.Facet == null || ex.Facet.Length == 0) { ostr.WriteStringSeq(Array.Empty <string>()); } else { string[] facetPath2 = { ex.Facet }; ostr.WriteStringSeq(facetPath2); } ostr.WriteString(ex.Operation); } catch (Ice.UnknownLocalException ex) { ostr.WriteByte(ReplyStatus.replyUnknownLocalException); ostr.WriteString(ex.Unknown); } catch (Ice.UnknownUserException ex) { ostr.WriteByte(ReplyStatus.replyUnknownUserException); ostr.WriteString(ex.Unknown); } catch (Ice.UnknownException ex) { ostr.WriteByte(ReplyStatus.replyUnknownException); ostr.WriteString(ex.Unknown); } catch (Ice.UserException ex) { ostr.WriteByte(ReplyStatus.replyUserException); // Exceptions are always marshaled in the sliced format: ostr.StartEncapsulation(current.Encoding, FormatType.SlicedFormat); ostr.WriteException(ex); ostr.EndEncapsulation(); } catch (Ice.Exception ex) { ostr.WriteByte(ReplyStatus.replyUnknownLocalException); ostr.WriteString(ex.ice_id() + "\n" + ex.StackTrace); } catch (System.Exception ex) { ostr.WriteByte(ReplyStatus.replyUnknownException); ostr.WriteString(ex.ToString()); } return(ostr); }
public void ice_writeMembers(OutputStream ostr) { ostr.WriteByte(this.major); ostr.WriteByte(this.minor); }