I'm writing a JavaFX application using Netty to implement a custom protocol. There is no session state but I would like to correlate a server response to a particular outbound request (and return the result to the correct JavaFX Task
.) So far I haven't been able to do so in the client code, because the responseFuture is a ChannelFuture<Void>
.
future = tcpBoostrap.connect(address, 3333).sync();
final Channel channel = future.awaitUninterruptibly().channel();
ChannelFuture responseFuture = channel.writeAndFlush(requestBuilder.build());
responseFuture.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture channelFuture) throws Exception {
if (channelFuture.isSuccess()) {
logger.debug("completed operation: {}", channelFuture.toString());
}
}
});
I tried looking how to configure a PipeLine
to somehow install ChannelHandlers
that would share the information in a shared context variable but I could not find anything significant.
Can anyone suggest the idiomatic place where I can stuff the UI Task that I can "complete" with the response in Netty?