Esempio n. 1
0
        public void StartService()
        {
            var binding = new NetPeerTcpBinding();

            binding.Security.Mode = SecurityMode.None;

            var endpoint = new ServiceEndpoint(
                ContractDescription.GetContract(typeof(IPing1)),
                binding,
                new EndpointAddress("net.p2p://SimpleP2P"));

            Host        = new PingImplementation();
            Host.MyHost = User;


            _factory = new System.ServiceModel.DuplexChannelFactory <IPing1>(new InstanceContext(Host), endpoint);

            var channel = _factory.CreateChannel();

            ((ICommunicationObject)channel).Open();

            // wait until after the channel is open to allow access.
            Channel        = channel;
            Host.myChannel = Channel;
        }
Esempio n. 2
0
 public void StopService()
 {
     ((ICommunicationObject)Channel).Close();
     if (_factory != null)
     {
         _factory.Close();
     }
     Channel = null;
 }