private IPublisher <StringMessage> StartIntradomainPublisher()
        {
            var connectionSettings = new IntradomainConnectionSettingsBuilder()
                                     .UsingSendTimeout(TimeSpan.FromHours(1))
                                     .Build();

            var communication = new IntradomainCommunication <StringMessage>(new IntradomainEndpoint("pubsubpayload"),
                                                                             new StringMessageSerializer(),
                                                                             ChannelSettings.GetDefault(),
                                                                             connectionSettings,
                                                                             null);

            return(Scenarios.PubSub.Publisher(communication));
        }
        private IRequester GetIntradomainRequester()
        {
            var connectionSettings = new IntradomainConnectionSettingsBuilder()
                                     .UsingSendTimeout(TimeSpan.FromHours(1))
                                     .UsingReceiveTimeout(TimeSpan.FromHours(1))
                                     .Build();

            var clientCommunication = new IntradomainCommunication <StringMessage>(new IntradomainEndpoint("payload"),
                                                                                   new StringMessageSerializer(),
                                                                                   ChannelSettings.GetDefault(),
                                                                                   connectionSettings,
                                                                                   null);

            return(Scenarios.RequestResponse.Requester(clientCommunication));
        }
        private NewChannelRequestAcceptor StartIntradomainServer()
        {
            var connectionSettings = new IntradomainConnectionSettingsBuilder()
                                     .UsingSendTimeout(TimeSpan.FromHours(1))
                                     .UsingReceiveTimeout(TimeSpan.FromHours(1))
                                     .Build();

            var communication = new IntradomainCommunication <StringMessage>(new IntradomainEndpoint("payload"),
                                                                             new StringMessageSerializer(),
                                                                             ChannelSettings.GetDefault(),
                                                                             connectionSettings,
                                                                             null);

            return(StartServer(communication));
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press '1' for TCP transport");
            Console.WriteLine("Press '2' for Intradomain transport");

            var transport = RequestTransport();

            Console.WriteLine();

            var serializer = new StringMessageSerializer();

            ICommunication <StringMessage> serverCommunication;

            if (transport == Transport.Tcp)
            {
                serverCommunication = new TcpCommunication <StringMessage>(new TcpEndpointData(IPAddress.Any, 2000), serializer);
            }
            else
            {
                serverCommunication = new IntradomainCommunication <StringMessage>(new IntradomainEndpoint("test"), serializer);
            }


            var server = Scenarios.RequestResponse.SetupServer(serverCommunication)
                         .UsingNewClientHandler((sender, a) => { Console.WriteLine("channel opened"); })
                         .UsingRequestHandler((sender, a) => { a.Response = new StringMessage(a.Request.Message.Replace("request", "response")); })
                         .UsingChannelClosedHandler((sender, a) => { Console.WriteLine("channel closed"); })
                         .Go();

            ICommunication <StringMessage> clientCommunication;

            if (transport == Transport.Tcp)
            {
                clientCommunication = new TcpCommunication <StringMessage>(new TcpEndpointData(IPAddress.Loopback, 2000), serializer);
            }
            else
            {
                clientCommunication = new IntradomainCommunication <StringMessage>(new IntradomainEndpoint("test"), serializer);
            }

            var r = Scenarios.RequestResponse.Requester(clientCommunication);

            using (r.Channel)
            {
                r.Channel.Open();

                var requester = new Requester(r.Channel);

                var requestMessage = new StringMessage($"request using {transport} transport");
                Console.WriteLine(requestMessage);

                var responseMessage = requester.Request(requestMessage);
                Console.WriteLine(responseMessage);

                r.Channel.Close();
            }

            server.Stop();

            Console.ReadKey();
        }