Ejemplo n.º 1
0
        /// <summary>
        /// Recreates a request from its on-wire representation.
        /// </summary>
        /// <param name="requestBytes">Data to deserialize</param>
        /// <returns>Deserialized request</returns>
        public RequestCall DeserializeRequestFromBytes(byte[] requestBytes)
        {
            if (requestBytes == null)
            {
                throw new ArgumentNullException(nameof(requestBytes));
            }

            // Before deserializing, check if the request specifies a watcher.  If it does, create a proxy watcher and add an entry to
            // the tracking data structure.  When proxyWatcher.Process is called by the backend, the corresponding message with WatcherCall
            // will be sent to the other side.
            RequestDefinitions.RequestCall call = this.protocol.DeserializeRequest(requestBytes, requestBytes.Length, this.UsedMarshalVersion);

            this.RegisterWatcher(call.Request, this.RegisterProxyWatcher);

            return(new RequestCall()
            {
                CallId = call.CallId,
                Request = BackendRequest.Wrap(call.Request),
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the on-wire representation of the given request.
        /// </summary>
        /// <param name="request">Request to serialize</param>
        /// <returns>Serialized data</returns>
        public byte[] SerializeRequestAsBytes(RequestCall request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            // Before serializing, check if the request has a watcher. If it does, add an entry to the tracking data strucuture
            // When a watchercall is received from the other side, this data structure will be used to get the correct watcher
            // by id and that watcher will be invoked.
            this.RegisterWatcher(request.Request.WrappedRequest, this.RegisterWrapperWatcher);

            RequestDefinitions.RequestCall call = new RequestDefinitions.RequestCall()
            {
                CallId  = request.CallId,
                Request = request.Request.WrappedRequest,
            };

            return(this.protocol.SerializeRequest(call, this.UsedMarshalVersion));
        }