| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | #nullable enable |
| | 4 | |
|
| | 5 | | namespace Ice; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// Represents a request received by a connection. It's the argument to <see cref="Object.dispatchAsync" />. |
| | 9 | | /// </summary> |
| | 10 | | public sealed class IncomingRequest |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Gets the current object for the request. |
| | 14 | | /// </summary> |
| 1 | 15 | | public Current current { get; } |
| | 16 | |
|
| | 17 | | /// <summary> |
| | 18 | | /// Gets the incoming stream buffer of the request. |
| | 19 | | /// </summary> |
| 1 | 20 | | public InputStream inputStream { get; } |
| | 21 | |
|
| | 22 | | /// <summary> |
| | 23 | | /// Gets the number of bytes in the request. |
| | 24 | | /// </summary> |
| | 25 | | /// <value>The number of bytes in the request. These are all the bytes starting with the identity of the target. |
| | 26 | | /// </value> |
| 1 | 27 | | public int size { get; } |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Initializes a new instance of the <see cref="IncomingRequest" /> class. |
| | 31 | | /// </summary> |
| | 32 | | /// <param name="requestId">The request ID. It's 0 for oneway requests.</param> |
| | 33 | | /// <param name="connection">The connection that received the request. It's null for collocated invocations.</param> |
| | 34 | | /// <param name="adapter">The object adapter to set in current.</param> |
| | 35 | | /// <param name="inputStream">The input stream buffer over the incoming Ice protocol request message. The stream is |
| | 36 | | /// positioned at the beginning of the request header - the next data to read is the identity of the target object. |
| | 37 | | /// </param> |
| 1 | 38 | | public IncomingRequest(int requestId, Connection? connection, ObjectAdapter adapter, InputStream inputStream) |
| | 39 | | { |
| 1 | 40 | | this.inputStream = inputStream; |
| | 41 | |
|
| | 42 | | // Read everything else from the input stream |
| 1 | 43 | | int start = inputStream.pos(); |
| 1 | 44 | | var identity = new Identity(inputStream); |
| | 45 | |
|
| 1 | 46 | | string facet = ""; |
| 1 | 47 | | string[] facetPath = inputStream.readStringSeq(); |
| 1 | 48 | | if (facetPath.Length > 0) |
| | 49 | | { |
| 1 | 50 | | if (facetPath.Length > 1) |
| | 51 | | { |
| 0 | 52 | | throw new MarshalException($"Received invalid facet path with {facetPath.Length} elements."); |
| | 53 | | } |
| 1 | 54 | | facet = facetPath[0]; |
| | 55 | | } |
| 1 | 56 | | string operation = inputStream.readString(); |
| 1 | 57 | | var mode = (OperationMode)inputStream.readByte(); |
| 1 | 58 | | var ctx = new Dictionary<string, string>(); |
| 1 | 59 | | int sz = inputStream.readSize(); |
| 1 | 60 | | while (sz-- > 0) |
| | 61 | | { |
| 1 | 62 | | string first = inputStream.readString(); |
| 1 | 63 | | string second = inputStream.readString(); |
| 1 | 64 | | ctx[first] = second; |
| | 65 | | } |
| | 66 | |
|
| 1 | 67 | | int encapsulationSize = inputStream.readInt(); |
| 1 | 68 | | var encoding = new EncodingVersion(inputStream); |
| | 69 | |
|
| 1 | 70 | | current = new Current(adapter, connection, identity, facet, operation, mode, ctx, requestId, encoding); |
| | 71 | |
|
| | 72 | | // Rewind to the start of the encapsulation |
| 1 | 73 | | inputStream.pos(inputStream.pos() - 6); |
| | 74 | |
|
| 1 | 75 | | size = inputStream.pos() - start + encapsulationSize; |
| 1 | 76 | | } |
| | 77 | | } |