예제 #1
0
        static async Task Main(string[] args)
        {
            if (args.Length > 0)
            {
                var pair = new EnginePair();
                pair.Engine1.Main = new CapnpEchoService();
                var echoer = (CapabilityReflection.CreateProxy <IEchoer>(pair.Endpoint2.QueryMain()) as IEchoer);

                await Run(echoer);
            }
            else
            {
                using var server = new TcpRpcServer();
                server.Main      = new CapnpEchoService();
                server.AddBuffering();
                server.StartAccepting(IPAddress.Any, 5002);
                using var client = new TcpRpcClient();
                client.AddBuffering();
                client.Connect("localhost", 5002);
                await client.WhenConnected;
                using var echoer = client.GetMain <IEchoer>();

                await Run(echoer);
            }
        }
예제 #2
0
        protected TcpRpcClient SetupClient()
        {
            var client = new TcpRpcClient();

            client.AddBuffering();
            client.Connect("localhost", TcpPort);
            return(client);
        }
예제 #3
0
 public void Setup()
 {
     _client = new TcpRpcClient("localhost", 5002);
     if (BufferSize > 0)
     {
         _client.AddBuffering(BufferSize);
     }
     _client.WhenConnected.Wait();
     _echoer  = _client.GetMain <IEchoer>();
     _payload = new byte[PayloadBytes];
     new Random().NextBytes(_payload);
 }
예제 #4
0
        protected static TcpRpcClient SetupClient(IPAddress addr, int port, TcpRpcTestOptions options = TcpRpcTestOptions.None)
        {
            var client = new TcpRpcClient();

            client.AddBuffering();
            if (options.HasFlag(TcpRpcTestOptions.ClientTracer))
            {
                client.AttachTracer(new FrameTracing.RpcFrameTracer(Console.Out, false));
            }
            if (options.HasFlag(TcpRpcTestOptions.ClientFluctStream))
            {
                client.InjectMidlayer(s => new FluctStream(s));
            }
            if (!options.HasFlag(TcpRpcTestOptions.ClientNoConnect))
            {
                client.Connect(addr.ToString(), port);
            }
            return(client);
        }