示例#1
0
        public void ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            responseHeaders = null;
            responseStream  = null;

            requestHeaders[CommonTransportKeys.RequestUri] = ((IMethodCallMessage)msg).Uri;

            // connect
            NamedPipeClient client = new NamedPipeClient(pipeName);
            NamedPipeSocket socket = client.Connect();
            IpcTransport    t      = new IpcTransport(socket);

            t.Write(requestHeaders, requestStream);
            t.Read(out responseHeaders, out responseStream);
            t.Close();
        }
示例#2
0
 void AsyncHandler(IClientChannelSinkStack sinkStack, IpcTransport transport)
 {
     try
     {
         // get the response headers and the response stream from the server
         ITransportHeaders responseHeaders;
         Stream            responseStream;
         transport.Read(out responseHeaders, out responseStream);
         transport.Close();
         sinkStack.AsyncProcessResponse(responseHeaders, responseStream);
     }
     catch (Exception ex)
     {
         sinkStack.DispatchException(ex);
     }
 }
示例#3
0
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            headers[CommonTransportKeys.RequestUri] = ((IMethodCallMessage)msg).Uri;

            // connect
            NamedPipeClient client = new NamedPipeClient(pipeName);
            NamedPipeSocket socket = client.Connect();
            IpcTransport    t      = new IpcTransport(socket);

            t.Write(headers, stream);

            // schedule an async call
            if (!RemotingServices.IsOneWay(((IMethodCallMessage)msg).MethodBase))
            {
                new AsyncResponse(AsyncHandler).BeginInvoke(sinkStack, t, null, null);
            }
        }
示例#4
0
        public void ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            responseHeaders = null;
            responseStream = null;

            requestHeaders[CommonTransportKeys.RequestUri] = ((IMethodCallMessage)msg).Uri;

            // connect
            NamedPipeClient client = new NamedPipeClient(pipeName);
            NamedPipeSocket socket = client.Connect();
            IpcTransport t = new IpcTransport(socket);
            t.Write(requestHeaders, requestStream);
            t.Read(out responseHeaders, out responseStream);
            t.Close();
        }
示例#5
0
 void AsyncHandler(IClientChannelSinkStack sinkStack, IpcTransport transport) 
 {
     try 
     {
         // get the response headers and the response stream from the server
         ITransportHeaders responseHeaders;
         Stream responseStream;
         transport.Read(out responseHeaders, out responseStream);
         transport.Close();
         sinkStack.AsyncProcessResponse(responseHeaders, responseStream);
     }
     catch (Exception ex) 
     {
         sinkStack.DispatchException(ex);
     }
 }
示例#6
0
        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            headers[CommonTransportKeys.RequestUri] = ((IMethodCallMessage)msg).Uri;

            // connect
            NamedPipeClient client = new NamedPipeClient(pipeName);
            NamedPipeSocket socket = client.Connect();
            IpcTransport t = new IpcTransport(socket);
            t.Write(headers, stream);

            // schedule an async call
            if (!RemotingServices.IsOneWay(((IMethodCallMessage)msg).MethodBase)) 
            {
                new AsyncResponse(AsyncHandler).BeginInvoke(sinkStack, t, null, null);
            }
        }
示例#7
0
        void ProcessClient(object state) 
        {
            try 
            {
                NamedPipeSocket socket = (NamedPipeSocket) state;

                ITransportHeaders requestHeaders;
                Stream requestStream;

                IpcTransport t = new IpcTransport(socket);
                t.Read(out requestHeaders, out requestStream);

                // parse the RequestUri
                string objectUri;
                string uri = (string) requestHeaders[CommonTransportKeys.RequestUri];
                IpcChannelHelper.Parse(uri, out objectUri);
                if (objectUri == null) objectUri = uri;
                requestHeaders[CommonTransportKeys.RequestUri] = objectUri;

                ServerChannelSinkStack stack = new ServerChannelSinkStack();
                stack.Push(this, null);

                IMessage responseMsg;
                ITransportHeaders responseHeaders;
                Stream responseStream;

                requestHeaders["__CustomErrorsEnabled"] = false;

                if (impersonate) 
                {
                    // TODO: Impersonate might throw exceptions. What to do with them?
                    socket.Impersonate();
                }

                ServerProcessing op = nextSink.ProcessMessage(
                    stack,
                    null,
                    requestHeaders,
                    requestStream,
                    out responseMsg,
                    out responseHeaders,
                    out responseStream
                    );

                if (impersonate) 
                {
                    NamedPipeSocket.RevertToSelf();
                }

                switch (op) 
                {
                    case ServerProcessing.Complete:
                        stack.Pop(this);
                        // send the response headers and the response data to the client
                        t.Write(responseHeaders, responseStream);
                        break;

                    case ServerProcessing.Async:
                        stack.StoreAndDispatch(nextSink, null);
                        break;

                    case ServerProcessing.OneWay:
                        break;
                }
            }
            catch (Exception)
            {
                // Console.WriteLine(ex);
            }
        }
示例#8
0
        void ProcessClient(object state)
        {
            try
            {
                NamedPipeSocket socket = (NamedPipeSocket)state;

                ITransportHeaders requestHeaders;
                Stream            requestStream;

                IpcTransport t = new IpcTransport(socket);
                t.Read(out requestHeaders, out requestStream);

                // parse the RequestUri
                string objectUri;
                string uri = (string)requestHeaders[CommonTransportKeys.RequestUri];
                IpcChannelHelper.Parse(uri, out objectUri);
                if (objectUri == null)
                {
                    objectUri = uri;
                }
                requestHeaders[CommonTransportKeys.RequestUri] = objectUri;

                ServerChannelSinkStack stack = new ServerChannelSinkStack();
                stack.Push(this, null);

                IMessage          responseMsg;
                ITransportHeaders responseHeaders;
                Stream            responseStream;

                requestHeaders["__CustomErrorsEnabled"] = false;

                if (impersonate)
                {
                    // TODO: Impersonate might throw exceptions. What to do with them?
                    socket.Impersonate();
                }

                ServerProcessing op = nextSink.ProcessMessage(
                    stack,
                    null,
                    requestHeaders,
                    requestStream,
                    out responseMsg,
                    out responseHeaders,
                    out responseStream
                    );

                if (impersonate)
                {
                    NamedPipeSocket.RevertToSelf();
                }

                switch (op)
                {
                case ServerProcessing.Complete:
                    stack.Pop(this);
                    // send the response headers and the response data to the client
                    t.Write(responseHeaders, responseStream);
                    break;

                case ServerProcessing.Async:
                    stack.StoreAndDispatch(nextSink, null);
                    break;

                case ServerProcessing.OneWay:
                    break;
                }
            }
            catch (Exception)
            {
                // Console.WriteLine(ex);
            }
        }