Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        static async Task Main(string[] args)
        {
            await Task.CompletedTask;
            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 RSocketDemoServer(a));
            });
            var task = host.ExecuteAsync(CancellationToken.None);

            Console.WriteLine("Server started...");

            while (true)
            {
                string cmd = Console.ReadLine();
                if (cmd == "clear")
                {
                    Console.Clear();
                    continue;
                }

                if (cmd == "exit")
                {
                    Console.Clear();
                    break;
                }
            }
        }