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(); }
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(); }
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(); }
public void Should_process_echo_command() { _client.Send("ECHO").Send("hello").Receive().ShouldEqual("hello"); }