示例#1
0
        private void OpenServer(PipeComEndPoint pipeComEndPoint)
        {
            ValidateNotInitialized();

            if (serviceHost == null)
            {
                serverProxy = new PipeProxy { PipeCom = this };

                serviceHost = new ServiceHost(
                    serverProxy,
                    new Uri[]
                    {
                        new Uri("net.pipe://localhost/"+networkId+"/"+channelId+"/"
                            + (pipeComEndPoint == PipeComEndPoint.Alpha ? "EndPointA" : "EndPointB") + "/")
                    });

                serviceHost.AddServiceEndpoint(typeof(IPipeProxy),
                    new NetNamedPipeBinding(), string.Empty);

                serviceHost.Open();
            }
            else
            {
                throw new InvalidOperationException("host already started");
            }
        }
示例#2
0
        private void OpenClient(PipeComEndPoint pipeComEndPoint)
        {
            ValidateNotInitialized();

            if (clientProxy == null)
            {
                var pipeFactory =
                    new ChannelFactory<IPipeProxy>(
                        new NetNamedPipeBinding(),
                        new EndpointAddress(
                            "net.pipe://localhost/" + networkId + "/" + channelId + "/" +
                            (pipeComEndPoint == PipeComEndPoint.Alpha ? "EndPointA" : "EndPointB")));

                clientProxy = pipeFactory.CreateChannel();
            }
            else
            {
                throw new InvalidOperationException("proxy already opened");
            }
        }