示例#1
0
        public void After_server_has_stoped_client_cannot_send_messages()
        {
            _client.Send("PING");
            Assert.That(_client.Receive(), Is.EqualTo("PONG"));

            Server.Stop();
            _client.Send("PING");
        }
        private void OneThreadExecution()
        {
            _countdown.Signal();

            var client = new HumbleClient();

            _mre.WaitOne();
            client.Connect("localhost", Server.Port);
            client.Send("wait");

            try
            {
                var data = client.Receive();
                if (data.Equals("1") == false)
                {
                    Assert.Ignore("Should receive 1 on thread " + Thread.CurrentThread.Name);
                }
            }
            catch (Exception exception)
            {
                Assert.Ignore("Exception on thread " + Thread.CurrentThread.Name + ": " + exception.Message);
            }

            _countdown.Signal();
        }
示例#3
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();
        }