Beispiel #1
0
        static void Main(string[] args)
        {
            var reliable = new ReliableSessionBindingElement()
            {
                Ordered = true
            };
            var unreliableElement       = new UnreliableElement(20);
            var transportBindingElement = new TcpTransportBindingElement();

            using (var host = new ServiceHost(typeof(ReliableSession.ReliableSession),
                                              new Uri("net.tcp://localhost:8888/service")))
            {
                host.AddServiceEndpoint(typeof(IReliableSessioon),
                                        new CustomBinding(reliable, unreliableElement, transportBindingElement),
                                        new Uri("net.tcp://localhost:8888/service"));
                host.Open();
                Console.WriteLine("服务已经开启");
                Console.Read();
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var reliable = new ReliableSessionBindingElement()
            {
                Ordered = true
            };
            var unreliableElement       = new UnreliableElement(20);
            var transportBindingElement = new TcpTransportBindingElement();
            var customBinding           = new CustomBinding(reliable, unreliableElement, transportBindingElement);
            var endpointAddress         = new EndpointAddress(new Uri("net.tcp://localhost:8888/service"));

            var client = new ReliableSession.ReliableSessionClient(customBinding, endpointAddress);

            Console.WriteLine(client.SayHello("Client"));
            for (int i = 0; i < 20; i++)
            {
                client.Talk($"Are you OK?{i}");
            }

            Console.WriteLine(client.SayByebye());
            Console.Read();
        }