Exemple #1
0
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            Stream compStream;

            Stream origStream = stream;
            long   origPos    = stream.Position;

            if ((checkedCompress && serverCanCompress) || (!checkedCompress && assumeCompress))
            {
                headers[CompressionHelper.CompressKey] = CompressionHelper.CompressedFlag;
                compStream = CompressionHelper.CompressStream(stream);
                sinkStack.Push(this, new RequestState(origStream, origPos, true, msg, headers));
            }
            else
            {
                headers[CompressionHelper.CompressKey] = CompressionHelper.CompressRequest;
                compStream = stream;
                sinkStack.Push(this, null);
            }

            try {
                _next.AsyncProcessRequest(sinkStack, msg, headers, compStream);
            }
            catch (Exception) {
            }
        }
        /// <summary>
        /// Processes an asynchronous request.
        /// </summary>
        /// <param name="sinkStack">Channel sink stack</param>
        /// <param name="msg">Message to processed</param>
        /// <param name="headers">Transport headers</param>
        /// <param name="stream">Request stream</param>
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            stream = CreateEnvelope(stream, headers);

            sinkStack.Push(this, null);
            _nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
        }
		public void AsyncProcessRequest(
			IClientChannelSinkStack sinkStack_in,
			IMessage msg_in,
			ITransportHeaders headers_in,
			Stream stream_in
		) {
			#region encrypt...
			headers_in[EncryptionHelper.X_ENCRYPT] = "1";
			headers_in[EncryptionHelper.X_CLIENTID] = this.clientid_;
			stream_in
				= EncryptionHelper.Encrypt(
					stream_in,
					false,
					this.keyspath_,
					this.clientid_
				); 
			#endregion

			sinkStack_in.Push(this, null);
			this.nextchannelsink_.AsyncProcessRequest(
				sinkStack_in,
				msg_in,
				headers_in,
				stream_in
			);
		} 
Exemple #4
0
        public void AsyncProcessRequest(
            IClientChannelSinkStack sinkStack_in,
            IMessage msg_in,
            ITransportHeaders headers_in,
            Stream stream_in
            )
        {
            #region encrypt...
            headers_in[EncryptionHelper.X_ENCRYPT]  = "1";
            headers_in[EncryptionHelper.X_CLIENTID] = this.clientid_;
            stream_in
                = EncryptionHelper.Encrypt(
                      stream_in,
                      false,
                      this.keyspath_,
                      this.clientid_
                      );
            #endregion

            sinkStack_in.Push(this, null);
            this.nextchannelsink_.AsyncProcessRequest(
                sinkStack_in,
                msg_in,
                headers_in,
                stream_in
                );
        }
 public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg,
                                 ITransportHeaders headers, Stream stream)
 {
     // перенаправляем вызов следующему приемнику в стеке
     sinkStack.Push(this, null);
     _nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
 }
Exemple #6
0
 public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
 {
     CompressSinkHelper.SetClientSupportCompressFlag(headers);
     stream = CompressSinkHelper.CompressStream(headers, stream);
     sinkStack.Push(this, null);
     _next.AsyncProcessRequest(sinkStack, msg, headers, stream);
 }
Exemple #7
0
        /// <summary>Requests asynchronous processing of a method call on the current sink.</summary>
        /// <param name="sinkStack">A stack of channel sinks.</param>
        /// <param name="msg">The message to process.</param>
        /// <param name="headers">The headers to send to the server.</param>
        /// <param name="stream">The stream headed to the transport sink.</param>
        public void AsyncProcessRequest(
            IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            AsyncProcessingState state = null;
            Stream encryptedStream     = null;
            Guid   id;

            lock (_transactionLock)            // could be a big lock... probably a faster way, but for now suffices
            {
                // Establish connection information with the server; the roundtrip will hopefully
                // only be done once, so we ensure that we have the necessary information.
                id = EnsureIDAndProvider(msg, headers);

                // Protect ourselves a bit.  If the asynchronous call fails because the server forgot about
                // us, we'll be in a bit of a fix.  We'll need the current arguments as we'll need
                // to retry the request synchronously.  Store them into a state object and use
                // that as the state when pushing ourself onto the stack.  That way, AsyncProcessResponse
                // have access to it.
                state = new AsyncProcessingState(msg, headers, ref stream, id);

                // Send encrypted message by encrypting the stream
                encryptedStream = SetupEncryptedMessage(headers, stream);
            }

            // Push ourselves onto the stack with the necessary state and forward on to the next sink
            sinkStack.Push(this, state);
            _next.AsyncProcessRequest(sinkStack, msg, headers, encryptedStream);
        }
Exemple #8
0
        /// <summary>
        /// Verarbeitet eine Anfragenachricht asynchron.
        /// </summary>
        /// <param name="sinkStack">Senkenstapel</param>
        /// <param name="msg">Remoting-Nachricht</param>
        /// <param name="headers">Anfrage-Header-Auflistung</param>
        /// <param name="stream">Anfrage-Datenstrom</param>
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            // Asynchroner Verarbeitungsstatus
            AsyncProcessingState state = null;

            // Verschlüsselter Datenstrom
            Stream encryptedStream = null;

            // Eindeutige Kennung der Sicherheitstransaktion
            Guid _secureTransactionID;

            lock (_lockObject)
            {
                // Sicherheitstransaktion starten
                _secureTransactionID = StartSecureTransaction(msg, headers);

                // Asynchronen Verarbeitungsstatus erzeugen
                state = new AsyncProcessingState(msg, headers, ref stream, _secureTransactionID);

                // Nachricht verschlüsseln
                encryptedStream = EncryptMessage(headers, stream);
            }
            // Aktuelle Senke auf den Senkenstapel legen (Damit ggf. die Verarbeitung der Antwort später asynchron aufgerufen werden kann)
            sinkStack.Push(this, state);

            // Nächste Kanalsenke aufrufen
            _next.AsyncProcessRequest(sinkStack, msg, headers, encryptedStream);
        }
 public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, 
     ITransportHeaders headers, Stream stream)
 {
     // перенаправляем вызов следующему приемнику в стеке
     sinkStack.Push(this, null);
     _nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
 }
        /// <summary>
        /// Processes an asynchronous request.
        /// </summary>
        /// <param name="sinkStack">Channel sink stack</param>
        /// <param name="msg">Message to processed</param>
        /// <param name="headers">Transport headers</param>
        /// <param name="stream">Request stream</param>
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            stream = CreateEnvelope(stream, headers);

            sinkStack.Push(this, null);
            _nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
        }
Exemple #11
0
 public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg,
     ITransportHeaders headers, Stream stream)
 {
     // never gets called, this sink is always first
     sinkStack.Push(this, null);
     _nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
 }
        /// <summary>
        /// Requests asynchronous processing of a method call on the current sink.
        /// </summary>
        /// <param name="sinkStack">A stack of channel sinks that called this sink.</param>
        /// <param name="msg">The message to process.</param>
        /// <param name="headers">The headers to add to the outgoing message heading to the server.</param>
        /// <param name="stream">The stream headed to the transport sink.</param>
        /// <exception cref="T:System.Security.SecurityException">The immediate caller does not have infrastructure permission. </exception>
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            // Push this onto the sink stack.
            sinkStack.Push(this, null);

            // Send the request to the client.
            _next.AsyncProcessRequest(sinkStack, msg, headers, stream);
        }
Exemple #13
0
        } // ProcessMessage

        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg,
                                        ITransportHeaders headers, Stream stream)
        {
            HttpWebRequest httpWebRequest = ProcessAndSend(msg, headers, stream);

            sinkStack.Push(this, httpWebRequest);

            httpWebRequest.BeginGetResponse(
                new AsyncCallback(this.OnHttpMessageReturn),
                sinkStack);
        } // AsyncProcessRequest
        void IClientChannelSink.AsyncProcessRequest(IClientChannelSinkStack sinkStack,
            IMessage msg, ITransportHeaders headers, Stream stream)
        {
            // process request
            object state = null;
            ProcessRequest(msg, headers, ref stream, ref state);

            // push to stack (to get a call to handle response)
            // and forward to the next
            sinkStack.Push(this, state);
            this.nextClientChannelSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
        }
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack,
                                        IMessage msg,
                                        ITransportHeaders headers,
                                        Stream stream)
        {
            // generate a compressed stream using NZipLib
            stream = CompressionHelper.getCompressedStreamCopy(stream);

            // push onto stack and forward the request
            sinkStack.Push(this, null);
            _nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
        }
Exemple #16
0
        /// <summary>
        /// Requests asynchronous processing of a method call on the current sink.
        /// </summary>
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack,
                                        IMessage msg, ITransportHeaders headers, Stream stream)
        {
            // process request
            object state = null;

            ProcessRequest(headers, ref stream);

            // push to stack (to get a call to handle response)
            // and forward to the next
            sinkStack.Push(this, state);
            this.FNextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
        }
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg,
                                        ITransportHeaders headers, Stream requestStream)
        {
            TcpConnection connection = null;
            bool          isOneWay   = RemotingServices.IsOneWay(((IMethodMessage)msg).MethodBase);

            try
            {
                if (headers == null)
                {
                    headers = new TransportHeaders();
                }
                headers [CommonTransportKeys.RequestUri] = ((IMethodMessage)msg).Uri;

                // Sends the stream using a connection from the pool
                // and creates a WorkItem that will wait for the
                // response of the server

                connection = TcpConnectionPool.GetConnection(_host, _port);
                TcpMessageIO.SendMessageStream(connection.Stream, requestStream, headers, connection.Buffer, isOneWay);
                connection.Stream.Flush();

                if (!isOneWay)
                {
                    sinkStack.Push(this, connection);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(data =>
                    {
                        try {
                            ReadAsyncTcpMessage(data);
                        }
                        catch {}
                    }), sinkStack);
                }
                else
                {
                    connection.Release();
                }
            }
            catch
            {
                if (connection != null)
                {
                    connection.Release();
                }
                if (!isOneWay)
                {
                    throw;
                }
            }
        }
Exemple #18
0
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack,
                                        IMessage msg,
                                        ITransportHeaders headers,
                                        Stream stream)
        {
            headers["X-Compress"] = "yes";

            stream = CompressionHelper.GetCompressedStreamCopy(stream);

            // push onto stack and forward the request

            sinkStack.Push(this, null);
            _nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
        }
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            Stream compStream;

            Stream origStream = stream;
            long origPos = stream.Position;

            if ((checkedCompress && serverCanCompress) || (!checkedCompress && assumeCompress)) {
                headers[CompressionHelper.CompressKey] = CompressionHelper.CompressedFlag;
                compStream = CompressionHelper.CompressStream(stream);
                sinkStack.Push(this, new RequestState(origStream, origPos, true, msg, headers));
            }
            else {
                headers[CompressionHelper.CompressKey] = CompressionHelper.CompressRequest;
                compStream = stream;
                sinkStack.Push(this, null);
            }

            try {
                _next.AsyncProcessRequest(sinkStack, msg, headers, compStream);
            }
            catch (Exception) {
            }
        }
Exemple #20
0
        public void AsyncProcessRequest(
            IClientChannelSinkStack stack,
            IMessage msg,
            ITransportHeaders headers,
            Stream stream
            )
        {
            #region Add hash to stream header
            string hash = HashHelper.GetHash(ref stream);
            headers[HashHelper.C_HASH_ITEM] = hash;
            //Debug.WriteLine("Client Side : client request stream hash is " + hash);
            #endregion

            stack.Push(this, null);
            _nextSink.AsyncProcessRequest(stack, msg, headers, stream);
        }
		public void AsyncProcessRequest (IClientChannelSinkStack sinkStack, IMessage msg,
			ITransportHeaders headers, Stream requestStream)
		{
			bool isOneWay = RemotingServices.IsOneWay (((IMethodMessage)msg).MethodBase);
			
			HttpWebRequest request = CreateRequest (headers);
	
			using (Stream targetStream = request.GetRequestStream ()) {
				CopyStream (requestStream, targetStream, 1024);
			}

			if (!isOneWay) {
				sinkStack.Push (this, request);
				request.BeginGetResponse (new AsyncCallback (AsyncProcessResponseCallback), sinkStack);
			}
		}
Exemple #22
0
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack,
                                        IMessage msg,
                                        ITransportHeaders headers,
                                        Stream stream)
        {
            byte[] IV;

            stream = EncryptionHelper.ProcessOutboundStream(stream,
                                                            _encryptionAlgorithm, _encryptionKey, out IV);

            headers["X-Encrypt"]   = "yes";
            headers["X-EncryptIV"] = Convert.ToBase64String(IV);

            // push onto stack and forward the request
            sinkStack.Push(this, null);
            _nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
        }
Exemple #23
0
        /// <summary>
        /// 异步处理请求
        /// </summary>
        /// <param name="sinkStack"></param>
        /// <param name="message"></param>
        /// <param name="requestHeaders"></param>
        /// <param name="requestStream"></param>
        public void AsyncProcessRequest(
            IClientChannelSinkStack sinkStack,
            IMessage message,
            ITransportHeaders requestHeaders,
            Stream requestStream)
        {
            // throw new NotImplementedException();
            // 尽量实现此方法,因为如果此接收器注册到接收器链当中,不排除客户端会异步调用

            IMethodCallMessage callMessage = message as IMethodCallMessage;

            Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}    开始处理异步请求:{callMessage.MethodName}");

            // 只有把当前接收器压入栈中时,异步响应(AsyncProcessResponse)的时候才会被执行
            sinkStack.Push(this, callMessage.MethodName);
            NextChannelSink.AsyncProcessRequest(sinkStack, message, requestHeaders, requestStream);
        }
Exemple #24
0
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg,
                                        ITransportHeaders headers, Stream requestStream)
        {
            bool isOneWay = RemotingServices.IsOneWay(((IMethodMessage)msg).MethodBase);

            HttpWebRequest request = CreateRequest(headers);

            using (Stream targetStream = request.GetRequestStream()) {
                CopyStream(requestStream, targetStream, 1024);
            }

            if (!isOneWay)
            {
                sinkStack.Push(this, request);
                request.BeginGetResponse(new AsyncCallback(AsyncProcessResponseCallback), sinkStack);
            }
        }
Exemple #25
0
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            AsyncProcessingState state = null;
            Stream encryptedStream     = null;
            Guid   id;

            lock (_transactionLock)
            {
                id = EnsureIDAndProvider(msg, headers);

                state = new AsyncProcessingState(msg, headers, ref stream, id);

                encryptedStream = SetupEncryptedMessage(headers, stream, null);
            }

            sinkStack.Push(this, state);
            _next.AsyncProcessRequest(sinkStack, msg, headers, encryptedStream);
        }
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack,
                                        IMessage msg, ITransportHeaders headers, Stream stream)
        {
            RemotingResult result = cache.GetPreviousResults(msg, headers, true);

            if (result == null)
            {
                _asyncMessage = msg;
                _asyncHeaders = headers;
                sinkStack.Push(this, null);
                _nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
            }
            else
            {
                _asyncMessage = null;
                AsyncProcessResponse(sinkStack, null, result.Headers, new MemoryStream(result.Response));
            }
        }
        /// <summary>
        /// Verarbeitet eine Anfragenachricht asynchron.
        /// </summary>
        /// <param name="sinkStack">Senkenstapel</param>
        /// <param name="msg">Remoting-Nachricht</param>
        /// <param name="headers">Anfrage-Header-Auflistung</param>
        /// <param name="stream">Anfrage-Datenstrom</param>
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            // Asynchroner Verarbeitungsstatus
            AsyncProcessingState state = null;

            lock (_lockObject)
            {
                // Asynchronen Verarbeitungsstatus erzeugen
                state = new AsyncProcessingState(msg, headers, ref stream, new Guid());

                //Methode aufrufen die Verarbeitung übernimmt
                DoProcessMessageBefore(msg, headers, stream);
            }
            // Aktuelle Senke auf den Senkenstapel legen (Damit ggf. die Verarbeitung der Antwort später asynchron aufgerufen werden kann)
            sinkStack.Push(this, state);

            // Nächste Kanalsenke aufrufen
            _next.AsyncProcessRequest(sinkStack, msg, headers, stream);
        }
		public void AsyncProcessRequest(
			IClientChannelSinkStack sinkStack_in,
			IMessage msg_in,
			ITransportHeaders headers_in,
			Stream stream_in
		) {
			#region compress...
			headers_in[CompressionHelper.X_COMPRESS] = "1";
			stream_in
				= CompressionHelper.GetCompressedStreamCopy(
					stream_in
				); 
			#endregion

			sinkStack_in.Push(this, null);
			this.nextchannelsink_.AsyncProcessRequest(
				sinkStack_in,
				msg_in,
				headers_in,
				stream_in
			);
		} 
Exemple #29
0
        public void AsyncProcessRequest(
            IClientChannelSinkStack sinkStack_in,
            IMessage msg_in,
            ITransportHeaders headers_in,
            Stream stream_in
            )
        {
            #region compress...
            headers_in[CompressionHelper.X_COMPRESS] = "1";
            stream_in
                = CompressionHelper.GetCompressedStreamCopy(
                      stream_in
                      );
            #endregion

            sinkStack_in.Push(this, null);
            this.nextchannelsink_.AsyncProcessRequest(
                sinkStack_in,
                msg_in,
                headers_in,
                stream_in
                );
        }
Exemple #30
0
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream requestStream)
        {
            UnixConnection connection = null;
            bool           flag       = RemotingServices.IsOneWay(((IMethodMessage)msg).MethodBase);

            try
            {
                if (headers == null)
                {
                    headers = new TransportHeaders();
                }
                headers["__RequestUri"] = ((IMethodMessage)msg).Uri;
                connection = UnixConnectionPool.GetConnection(this._path);
                UnixMessageIO.SendMessageStream(connection.Stream, requestStream, headers, connection.Buffer);
                connection.Stream.Flush();
                if (flag)
                {
                    connection.Release();
                }
                else
                {
                    sinkStack.Push(this, connection);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(this.ReadAsyncUnixMessage), sinkStack);
                }
            }
            catch
            {
                if (connection != null)
                {
                    connection.Release();
                }
                if (!flag)
                {
                    throw;
                }
            }
        }
Exemple #31
0
        /// <summary>
        /// Requests asynchronous processing of a method call on the current sink.
        /// </summary>
        /// <param name="sinkStack">A stack of channel sinks that called this sink.</param>
        /// <param name="msg">The message to process.</param>
        /// <param name="headers">The headers to add to the outgoing message heading to the server.</param>
        /// <param name="stream">The stream headed to the transport sink.</param>
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            AsyncProcessingState state = null;
            Stream encryptedStream     = null;
            Guid   _secureTransactionID;

            lock (_lockObject)
            {
                // Start the secure transaction and save its identifier
                _secureTransactionID = StartSecureTransaction(msg, headers);

                // Prepare asynchronous state
                state = new AsyncProcessingState(msg, headers, ref stream, _secureTransactionID);

                // Encrypt the message
                encryptedStream = EncryptMessage(headers, stream);
            }

            // Push the current sink onto the sink stack so the processing of the response can be invoked asynchronously later
            sinkStack.Push(this, state);

            // Pass the message on to the next sink
            _next.AsyncProcessRequest(sinkStack, msg, headers, encryptedStream);
        }
Exemple #32
0
        } // ProcessMessage


        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg,
                                        ITransportHeaders headers, Stream stream)
        {
            HttpWebRequest httpWebRequest = ProcessAndSend(msg, headers, stream);

            sinkStack.Push(this, httpWebRequest);
            
            httpWebRequest.BeginGetResponse(
                new AsyncCallback(this.OnHttpMessageReturn), 
                sinkStack);
        } // AsyncProcessRequest
        /// <summary>
        /// Requests asynchronous processing of a method call on the current sink.
        /// </summary>
        /// <param name="sinkStack">A stack of channel sinks that called this sink.</param>
        /// <param name="msg">The message to process.</param>
        /// <param name="headers">The headers to add to the outgoing message heading to the server.</param>
        /// <param name="stream">The stream headed to the transport sink.</param>
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            AsyncProcessingState state = null;
            Stream encryptedStream = null;
            Guid _secureTransactionID;

            lock (_lockObject)
            {
                // Start the secure transaction and save its identifier
                _secureTransactionID = StartSecureTransaction(msg, headers);

                // Prepare asynchronous state
                state = new AsyncProcessingState(msg, headers, ref stream, _secureTransactionID);

                // Encrypt the message
                encryptedStream = EncryptMessage(headers, stream);
            }

            // Push the current sink onto the sink stack so the processing of the response can be invoked asynchronously later
            sinkStack.Push(this, state);

            // Pass the message on to the next sink
            _next.AsyncProcessRequest(sinkStack, msg, headers, encryptedStream);
        }
 public void AsyncProcessRequest(
     IClientChannelSinkStack sinkStack,
     IMessage msg,
     ITransportHeaders headers,
     Stream stream)
 {
     // Push this onto the sink stack.
     sinkStack.Push(this, null);
     // Send the request to the client.
     _next.AsyncProcessRequest(sinkStack, msg, headers, stream);
 }
        /// <summary>
        /// Verarbeitet eine Anfragenachricht asynchron.
        /// </summary>
        /// <param name="sinkStack">Senkenstapel</param>
        /// <param name="msg">Remoting-Nachricht</param>
        /// <param name="headers">Anfrage-Header-Auflistung</param>
        /// <param name="stream">Anfrage-Datenstrom</param>
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            // Asynchroner Verarbeitungsstatus
            AsyncProcessingState state = null;

            lock (_lockObject)
            {

                // Asynchronen Verarbeitungsstatus erzeugen
                state = new AsyncProcessingState(msg, headers, ref stream, new Guid());

                //Methode aufrufen die Verarbeitung übernimmt
                DoProcessMessageBefore(msg, headers, stream);

            }
            // Aktuelle Senke auf den Senkenstapel legen (Damit ggf. die Verarbeitung der Antwort später asynchron aufgerufen werden kann)
            sinkStack.Push(this, state);

            // Nächste Kanalsenke aufrufen
            _next.AsyncProcessRequest(sinkStack, msg, headers, stream);
        }
        /// <summary>
        /// Verarbeitet eine Anfragenachricht asynchron.
        /// </summary>
        /// <param name="sinkStack">Senkenstapel</param>
        /// <param name="msg">Remoting-Nachricht</param>
        /// <param name="headers">Anfrage-Header-Auflistung</param>
        /// <param name="stream">Anfrage-Datenstrom</param>
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            // Asynchroner Verarbeitungsstatus
            AsyncProcessingState state = null;

            // Verschlüsselter Datenstrom
            Stream encryptedStream = null;

            // Eindeutige Kennung der Sicherheitstransaktion
            Guid _secureTransactionID;

            lock (_lockObject)
            {
                // Sicherheitstransaktion starten
                _secureTransactionID = StartSecureTransaction(msg, headers);

                // Asynchronen Verarbeitungsstatus erzeugen
                state = new AsyncProcessingState(msg, headers, ref stream, _secureTransactionID);

                // Nachricht verschlüsseln
                encryptedStream = EncryptMessage(headers, stream);
            }
            // Aktuelle Senke auf den Senkenstapel legen (Damit ggf. die Verarbeitung der Antwort später asynchron aufgerufen werden kann)
            sinkStack.Push(this, state);

            // Nächste Kanalsenke aufrufen
            _next.AsyncProcessRequest(sinkStack, msg, headers, encryptedStream);
        }
 public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg,
                                 ITransportHeaders headers, Stream stream)
 {
     sinkStack.Push(this, null);
     nextClientSink.AsyncProcessRequest(sinkStack, msg, headers, stream);
 }
        /// <summary>Requests asynchronous processing of a method call on the current sink.</summary>
        /// <param name="sinkStack">A stack of channel sinks.</param>
        /// <param name="msg">The message to process.</param>
        /// <param name="headers">The headers to send to the server.</param>
        /// <param name="stream">The stream headed to the transport sink.</param>
        public void AsyncProcessRequest(
			IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            AsyncProcessingState state = null;
            Stream encryptedStream = null;
            Guid id;

            lock(_transactionLock) // could be a big lock... probably a faster way, but for now suffices
            {
                // Establish connection information with the server; the roundtrip will hopefully
                // only be done once, so we ensure that we have the necessary information.
                id = EnsureIDAndProvider(msg, headers);

                // Protect ourselves a bit.  If the asynchronous call fails because the server forgot about
                // us, we'll be in a bit of a fix.  We'll need the current arguments as we'll need
                // to retry the request synchronously.  Store them into a state object and use
                // that as the state when pushing ourself onto the stack.  That way, AsyncProcessResponse
                // have access to it.
                state = new AsyncProcessingState(msg, headers, ref stream, id);

                // Send encrypted message by encrypting the stream
                encryptedStream = SetupEncryptedMessage(headers, stream);
            }

            // Push ourselves onto the stack with the necessary state and forward on to the next sink
            sinkStack.Push(this, state);
            _next.AsyncProcessRequest(sinkStack, msg, headers, encryptedStream);
        }
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            AsyncProcessingState state = null;
            Stream encryptedStream = null;
            Guid id;

            lock (_transactionLock)
            {
                id = EnsureIDAndProvider(msg, headers);

                state = new AsyncProcessingState(msg, headers, ref stream, id);

                encryptedStream = SetupEncryptedMessage(headers, stream, null);
            }

            sinkStack.Push(this, state);
            _next.AsyncProcessRequest(sinkStack, msg, headers, encryptedStream);
        }
 public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage message, ITransportHeaders headers, Stream stream)
 {
     stream = Zip.Compress(stream);
     sinkStack.Push(this, null);
     this.m_NextSink.AsyncProcessRequest(sinkStack, message, headers, stream);
 }
		public void AsyncProcessRequest (IClientChannelSinkStack sinkStack, IMessage msg,
			ITransportHeaders headers, Stream requestStream)
		{
			TcpConnection connection = null;
			bool isOneWay = RemotingServices.IsOneWay (((IMethodMessage)msg).MethodBase);

			try
			{
				if (headers == null) headers = new TransportHeaders();
				headers [CommonTransportKeys.RequestUri] = ((IMethodMessage)msg).Uri;
				
				// Sends the stream using a connection from the pool
				// and creates a WorkItem that will wait for the
				// response of the server

				connection = TcpConnectionPool.GetConnection (_host, _port);
				TcpMessageIO.SendMessageStream (connection.Stream, requestStream, headers, connection.Buffer);
				connection.Stream.Flush ();

				if (!isOneWay) 
				{
					sinkStack.Push (this, connection);
					ThreadPool.QueueUserWorkItem (new WaitCallback(ReadAsyncTcpMessage), sinkStack);
				}
				else
					connection.Release();
			}
			catch
			{
				if (connection != null) connection.Release();
				if (!isOneWay) throw;
			}
		}