/// <summary>
        /// Process this IRequest and update the given <b>Response</b> with
        /// the result.
        /// </summary>
        /// <remarks>
        /// Implementations of this method are free to throw an exception
        /// while processing the IRequest. An exception will result in the
        /// <b>Response</b> being marked as a failure that the
        /// <b>Response</b> result will be the exception itself.
        /// </remarks>
        /// <param name="response">
        /// The <b>Response</b> that will be sent back to the requestor.
        /// </param>
        /// <exception cref="Exception">
        /// If exception occurs during execution.
        /// </exception>
        protected override void OnRun(Response response)
        {
            IChannel channel0 = Channel;

            Debug.Assert(channel0.Id == 0);

            Connection connection = (Connection)channel0.Connection;

            Debug.Assert(connection != null);

            Peer module = (Peer)Channel.Receiver;
            int  id     = ChannelId;

            connection.AcceptChannelRequest
            (
                id,
                module.AssertIdentityToken(module.DeserializeIdentityToken(IdentityToken))
            );

            // Cannot use ImplVersion here as channel0 is established prior to protocol
            // version negotiation.  Instead check the negotiated version directly on the connection's
            // MessageFactoryMap.
            MessageFactory clientFactory = (MessageFactory)connection.MessageFactoryMap
                                           [channel0.MessageFactory.Protocol.Name];

            if (clientFactory != null && clientFactory.Version >= 3)
            {
                response.Result = id;
            }
        }
Example #2
0
        /// <summary>
        /// Process this IRequest and update the given <b>Response</b> with
        /// the result.
        /// </summary>
        /// <remarks>
        /// Implementations of this method are free to throw an exception
        /// while processing the IRequest. An exception will result in the
        /// <b>Response</b> being marked as a failure that the
        /// <b>Response</b> result will be the exception itself.
        /// </remarks>
        /// <param name="response">
        /// The <b>Response</b> that will be sent back to the requestor.
        /// </param>
        /// <exception cref="Exception">
        /// If exception occurs during execution.
        /// </exception>
        protected override void OnRun(Response response)
        {
            IChannel channel0 = Channel;

            Debug.Assert(channel0.Id == 0);

            Connection connection = (Connection)channel0.Connection;

            Debug.Assert(connection != null);

            Peer      peer     = (Peer)channel0.Receiver;
            IReceiver receiver = peer.GetReceiver(ReceiverName);

            if (receiver == null)
            {
                throw new ArgumentException("unknown receiver: " + ReceiverName);
            }

            response.Result = connection.OpenChannelRequest(ProtocolName,
                                                            channel0.Serializer,
                                                            receiver,
                                                            peer.AssertIdentityToken(peer.DeserializeIdentityToken(IdentityToken)));
        }