| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | #nullable enable |
| | 4 | |
|
| | 5 | | using Ice.Internal; |
| | 6 | |
|
| | 7 | | namespace Ice; |
| | 8 | |
|
| | 9 | | /// <summary> |
| | 10 | | /// Represents the response to an incoming request. It's returned by <see cref="Object.dispatchAsync" />. |
| | 11 | | /// </summary> |
| | 12 | | public sealed class OutgoingResponse |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// Gets the exception ID of the response. |
| | 16 | | /// </summary> |
| | 17 | | /// <value>The exception ID of the response. It's null when replyStatus is <see cref="ReplyStatus.Ok" /> or |
| | 18 | | /// <see cref="ReplyStatus.UserException"/> . Otherwise, this ID is the value returned by |
| | 19 | | /// <see cref="LocalException.ice_id()" />. For other exceptions, this ID is the full name of the exception's type. |
| | 20 | | /// </value> |
| 1 | 21 | | public string? exceptionId { get; } |
| | 22 | |
|
| | 23 | | /// <summary> |
| | 24 | | /// Gets the full details of the exception marshaled into the response. |
| | 25 | | /// </summary> |
| | 26 | | /// <value>The exception details, usually produced by calling <see cref="object.ToString" /> on the exception. It's |
| | 27 | | /// null when replyStatus is <see cref="ReplyStatus.Ok" /> or <see cref="ReplyStatus.UserException"/>.</value> |
| 0 | 28 | | public string? exceptionDetails { get; } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Gets the output stream buffer of the response. This output stream should not be written to after construction. |
| | 32 | | /// </summary> |
| 1 | 33 | | public OutputStream outputStream { get; } |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// Gets the reply status of the response. |
| | 37 | | /// </summary> |
| 1 | 38 | | public ReplyStatus replyStatus { get; } |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// Gets the number of bytes in the response's payload. |
| | 42 | | /// </summary> |
| 1 | 43 | | public int size => outputStream.isEmpty() ? 0 : outputStream.size() - Protocol.headerSize - 4; |
| | 44 | |
|
| | 45 | | /// <summary> |
| | 46 | | /// Initializes a new instance of the <see cref="OutgoingResponse" /> class. |
| | 47 | | /// </summary> |
| | 48 | | /// <param name="replyStatus">The reply status.</param> |
| | 49 | | /// <param name="exceptionId">The ID of the exception, when the response carries an exception other than a user |
| | 50 | | /// exception.</param> |
| | 51 | | /// <param name="exceptionDetails">The full details of the exception, when the response carries an exception other |
| | 52 | | /// than a user exception.</param> |
| | 53 | | /// <param name="outputStream">The output stream that holds the response.</param> |
| 1 | 54 | | public OutgoingResponse( |
| 1 | 55 | | ReplyStatus replyStatus, |
| 1 | 56 | | string? exceptionId, |
| 1 | 57 | | string? exceptionDetails, |
| 1 | 58 | | OutputStream outputStream) |
| | 59 | | { |
| 1 | 60 | | this.replyStatus = replyStatus; |
| 1 | 61 | | this.exceptionId = exceptionId; |
| 1 | 62 | | this.exceptionDetails = exceptionDetails; |
| 1 | 63 | | this.outputStream = outputStream; |
| 1 | 64 | | } |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Initializes a new instance of the <see cref="OutgoingResponse" /> class with the <see cref="ReplyStatus.Ok" /> |
| | 68 | | /// status. |
| | 69 | | /// </summary> |
| | 70 | | /// <param name="outputStream">The output stream that holds the response.</param> |
| | 71 | | public OutgoingResponse(OutputStream outputStream) |
| 1 | 72 | | : this(ReplyStatus.Ok, exceptionId: null, exceptionDetails: null, outputStream) |
| | 73 | | { |
| 1 | 74 | | } |
| | 75 | | } |