コード例 #1
0
        public void ScatteredTransfer()
        {
            using (var server = new TcpRpcServer(IPAddress.Any, TcpPort))
                using (var client = new TcpRpcClient())
                {
                    server.InjectMidlayer(s => new ScatteringStream(s, 7));
                    client.InjectMidlayer(s => new ScatteringStream(s, 10));
                    client.Connect("localhost", TcpPort);
                    client.WhenConnected.Wait();

                    var counters = new Counters();
                    server.Main = new TestInterfaceImpl(counters);
                    using (var main = client.GetMain <ITestInterface>())
                    {
                        for (int i = 0; i < 100; i++)
                        {
                            var request1 = main.Foo(123, true, default);
                            var request3 = Assert.ThrowsExceptionAsync <RpcException>(() => main.Bar(default));
コード例 #2
0
        public void ScatteredTransfer()
        {
            (var addr, int port) = TcpManager.Instance.GetLocalAddressAndPort();

            using (var server = new TcpRpcServer(addr, port))
                using (var client = new TcpRpcClient())
                {
                    server.InjectMidlayer(s => new ScatteringStream(s, 7));
                    client.InjectMidlayer(s => new ScatteringStream(s, 10));
                    client.Connect(addr.ToString(), port);
                    //client.WhenConnected.Wait();

                    var counters = new Counters();
                    server.Main = new TestInterfaceImpl(counters);
                    using (var main = client.GetMain <ITestInterface>())
                    {
                        for (int i = 0; i < 100; i++)
                        {
                            var request1 = main.Foo(123, true, default);
                            var request3 = Assert.ThrowsExceptionAsync <RpcException>(() => main.Bar(default));