コード例 #1
0
        private void AsyncProcessMessageOnce(IMessage msg,
                                             Ior target, IMessageSink replySink)
        {
            IIorProfile selectedProfile;
            uint        reqId;

            try {
                // allocate (reserve) connection
                GiopClientConnectionDesc conDesc = AllocateConnection(msg, target, out selectedProfile, out reqId);
                SimpleGiopMsg.SetMessageAsyncRequest(msg); // mark message as async, needed for portable interceptors
                ITransportHeaders requestHeaders;
                Stream            requestStream;
                SerialiseRequest(msg, selectedProfile, conDesc, reqId,
                                 out requestHeaders, out requestStream);
                // pass the serialised GIOP-request to the first stream handling sink
                // this sink is the last sink in the message handling sink chain, therefore the reply sink chain of all the previous message handling
                // sink is passed to the ClientChannelSinkStack, which will inform this chain of the received reply
                ClientChannelSinkStack clientSinkStack = new ClientChannelSinkStack(replySink);
                AsyncProcessingData    asyncData       = new AsyncProcessingData(msg, conDesc);
                clientSinkStack.Push(this, asyncData); // push the formatter onto the sink stack, to get the chance to handle the incoming reply stream
                // forward the message to the next sink
                m_nextSink.AsyncProcessRequest(clientSinkStack, msg, requestHeaders, requestStream);
                // for oneway messages, release the connections for future use
                if ((msg is IMethodCallMessage) && GiopMessageHandler.IsOneWayCall((IMethodCallMessage)msg))
                {
                    m_conManager.RequestOnConnectionCompleted(msg);  // release the connection, because this interaction is complete
                }
            } catch {
                // release the connection, if something went wrong during connection allocation and send
                m_conManager.RequestOnConnectionCompleted(msg); // release the connection, because this interaction is complete
                throw;
            }
        }
コード例 #2
0
        public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state,
                                         ITransportHeaders headers, Stream stream)
        {
            // client side formatter is the last sink in the chain accessing the serialised message, therefore this method is called on the return path
            AsyncProcessingData asyncData  = (AsyncProcessingData)state; // retrieve the request msg stored on the channelSinkStack
            IMessage            requestMsg = asyncData.RequestMsg;

            try {
                IMessage responseMsg;
                try {
                    GiopClientConnectionDesc conDesc = (GiopClientConnectionDesc)asyncData.ConDesc;
                    responseMsg = DeserialiseResponse(stream, headers,
                                                      requestMsg, conDesc);
                } finally {
                    m_conManager.RequestOnConnectionCompleted(requestMsg); // release the connection, because this interaction is complete
                }
                sinkStack.DispatchReplyMessage(responseMsg);               // dispatch the result message to the message handling reply sink chain
            } catch (Exception e) {
                sinkStack.DispatchException(e);                            // dispatch the exception to the message handling reply sink chain
            }
        }
コード例 #3
0
 private void AsyncProcessMessageOnce(IMessage msg,
                                          Ior target, IMessageSink replySink) {
     IIorProfile selectedProfile;
     uint reqId;
     try {
         // allocate (reserve) connection
         GiopClientConnectionDesc conDesc = AllocateConnection(msg, target, out selectedProfile, out reqId);
         SimpleGiopMsg.SetMessageAsyncRequest(msg); // mark message as async, needed for portable interceptors
         ITransportHeaders requestHeaders;
         Stream requestStream;
         SerialiseRequest(msg, selectedProfile, conDesc, reqId,
                          out requestHeaders, out requestStream);
         // pass the serialised GIOP-request to the first stream handling sink
         // this sink is the last sink in the message handling sink chain, therefore the reply sink chain of all the previous message handling
         // sink is passed to the ClientChannelSinkStack, which will inform this chain of the received reply
         ClientChannelSinkStack clientSinkStack = new ClientChannelSinkStack(replySink);
         AsyncProcessingData asyncData = new AsyncProcessingData(msg, conDesc);
         clientSinkStack.Push(this, asyncData); // push the formatter onto the sink stack, to get the chance to handle the incoming reply stream
         // forward the message to the next sink
         m_nextSink.AsyncProcessRequest(clientSinkStack, msg, requestHeaders, requestStream);
         // for oneway messages, release the connections for future use
         if ((msg is IMethodCallMessage) && GiopMessageHandler.IsOneWayCall((IMethodCallMessage)msg)) {
              m_conManager.RequestOnConnectionCompleted(msg); // release the connection, because this interaction is complete
         }
     } catch {
         // release the connection, if something went wrong during connection allocation and send
         m_conManager.RequestOnConnectionCompleted(msg); // release the connection, because this interaction is complete
         throw;
     }
 }