static async Task Main(string[] args) { //should run RSocketDemo.Server first. Console.WriteLine($"Enter any key to launch the client..."); Console.ReadKey(); Console.WriteLine($"Client started...{Thread.CurrentThread.ManagedThreadId}"); ClientSocketTransport socketTransport = new ClientSocketTransport("127.0.0.1", 8888); _client = new RSocketDemoClient(socketTransport, new RSocketOptions() { InitialRequestSize = int.MaxValue, KeepAlive = TimeSpan.FromSeconds(60), Lifetime = TimeSpan.FromSeconds(120) }); await _client.ConnectAsync(data : Encoding.UTF8.GetBytes("setup.data"), metadata : Encoding.UTF8.GetBytes("setup.metadata")); while (true) { await RequestFireAndForgetTest(); ReadKey(); await RequestResponseTest(); ReadKey(); await RequestStreamTest(); ReadKey(); await RequestStreamTest1(); ReadKey(); await RequestChannelTest(); ReadKey(); await RequestChannelTest(metadata : "echo"); ReadKey(); await RequestChannelTest1(); ReadKey(); await RequestChannelTest_Backpressure(); //backpressure ReadKey(); await ErrorTest(); ReadKey(); await RunParallel(); ReadKey(); Console.WriteLine("-----------------------------------over-----------------------------------"); Console.ReadKey(); } Console.ReadKey(); }
static async Task Main(string[] args) { Console.WriteLine("Run RSocketDemo.Client and RSocketDemo.Server please."); Console.ReadKey(); await Test(); IPAddress iP = IPAddress.Parse("127.0.0.1"); IPEndPoint iPEndPoint = new IPEndPoint(iP, 8888); SocketListenerFactory socketListenerFactory = new SocketListenerFactory(); RSocketHost host = new RSocketHost(socketListenerFactory, iPEndPoint, a => { return(new EchoServer(a)); }); var hostTask = host.ExecuteAsync(CancellationToken.None); ClientSocketTransport socketTransport = await ClientSocketTransport.Create("tcp://127.0.0.1:8888/"); _client = new EchoRSocketClient(socketTransport, new RSocketOptions() { InitialRequestSize = int.MaxValue }); await _client.ConnectAsync(); Console.ReadKey(); }