Looking at Netty in Action and some SO posts, I saw that in order to talk
to another system, you can use Bootstrap() to create a new client and
attach it to the current eventLoop. Looking at the proxy example, it's
done when the initial server is bootstrapped as well. So I tried
public void start(final ApplicationContext applicationContext) throws
Exception {
NioEventLoopGroup bossGroup = new NioEventLoopGroup(1);
NioEventLoopGroup workerGroup = new NioEventLoopGroup();
try {
bootstrap.group(bossGroup,
workerGroup).channel(NioServerSocketChannel.class)
.handler(new
LoggingHandler(LogLevel.INFO)).childHandler(new
ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws
Exception {
ch.pipeline().addLast(new ServerHandlerImpl());
ch.pipeline().addLast(new SomeOtherHandler());
}
@Override
protected void channelActive(ChannelHandlerContext
ctx) throws Exception {
Bootstrap clientBootstrap = new Bootstrap();
clientBootstrap.channel(NioSocketChannel.class)
.handler(new
ChannelInitializer<SocketChannel>() {
@Override
protected void
initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new
CredentialsClientHandler());
}
});
clientBootstrap.group(ctx.channel().eventLoop());
ChannelFuture future =
clientBootstrap.connect(host, port);
}
});
So when a message comes in and it reaches the ServerHandlerImpl, I want it
to then route its message to CredentialsClientHandler that would send a
message to another server, check the credentials, and then resume the rest
of the pipeline. In ServerHandlerImpl, how do I "send a message" down the
other handler and not down SomeOtherHandler?
--
You received this message because you are subscribed to the Google Groups
"Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/netty/758497d8-5293-4ff3-bce9-148b1ef86af0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.