Esempio n. 1
0
        void SingleCompositeBufferWrite0(ServerBootstrap sb, Bootstrap cb)
        {
            sb.ChildHandler(new ActionChannelInitializer <TcpChannel>(channel =>
            {
                channel.Pipeline.AddLast(new ServerHandler());
            }));

            var clientHandler = new ClientHandler();

            cb.Handler(new ActionChannelInitializer <TcpChannel>(channel =>
            {
                channel.Pipeline.AddLast(clientHandler);
            }));

            // start server
            Task <IChannel> task = sb.BindAsync(LoopbackAnyPort);

            Assert.True(task.Wait(DefaultTimeout), "Server bind timed out");
            this.serverChannel = task.Result;
            Assert.NotNull(this.serverChannel.LocalAddress);
            var endPoint = (IPEndPoint)this.serverChannel.LocalAddress;

            // connect to server
            task = cb.ConnectAsync(endPoint);
            Assert.True(task.Wait(DefaultTimeout), "Connect to server timed out");
            this.clientChannel = task.Result;
            Assert.NotNull(this.clientChannel.LocalAddress);

            IByteBuffer expected = NewCompositeBuffer(this.clientChannel.Allocator);

            clientHandler.AssertReceived(expected);
        }