Пример #1
0
        public static void Main(string[] args)
        {
            //// create the server, configure echo command and start listening
            var server = new HumbleServer();
            server.AddCommand("echo", () => new EchoCommand());
            server.Start(0);

            //// create the client, connect to the server, send the command and the parameters
            var client = new HumbleClient();
            client.Connect("localhost", server.Port);
            client.Send("echo").Send("hello world");

            Console.WriteLine("Client received: " + client.Receive());
            Console.ReadKey();
        }
Пример #2
0
        public static void Main(string[] args)
        {
            //// create the server, configure echo command and start listening
            var server = new HumbleServer();

            server.AddCommand("echo", () => new EchoCommand());
            server.Start(0);

            //// create the client, connect to the server, send the command and the parameters
            var client = new HumbleClient();

            client.Connect("localhost", server.Port);
            client.Send("echo").Send("hello world");

            Console.WriteLine("Client received: " + client.Receive());
            Console.ReadKey();
        }
Пример #3
0
        public void Should_accept_differents_delimiters_for_differents_instances()
        {
            var server1 = new HumbleServer(Framing.Delimitered, "[DEL1]");
            var server2 = new HumbleServer(Framing.Delimitered, "[DEL2]");

            server1.AddCommand("echo", () => new EchoCommand());
            server2.AddCommand("echo", () => new EchoCommand());

            server1.Start(0);
            server2.Start(0);

            var client1 = new HumbleClient(Framing.Delimitered, "[DEL1]");
            var client2 = new HumbleClient(Framing.Delimitered, "[DEL2]");

            client1.Connect("localhost", server1.Port);
            client2.Connect("localhost", server2.Port);

            client1.Send("echohello1").Receive().ShouldEqual("hello1");
            client2.Send("echohello2").Receive().ShouldEqual("hello2");

            server1.Stop();
            server2.Stop();
        }