use of io.netty.channel.udt.UdtChannel in project netty by netty.
the class MsgEchoPeerBase method run.
public void run() throws Exception {
// Configure the peer.
final ThreadFactory connectFactory = new DefaultThreadFactory("rendezvous");
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER);
try {
final Bootstrap boot = new Bootstrap();
boot.group(connectGroup).channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS).handler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch) throws Exception {
ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new MsgEchoPeerHandler(messageSize));
}
});
// Start the peer.
final ChannelFuture f = boot.connect(peer, self).sync();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
} finally {
// Shut down the event loop to terminate all threads.
connectGroup.shutdownGracefully();
}
}
Aggregations