调用channelInactive后的java链操作
我有一些清理代码:
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
clean-up code
super.channelInactive(ctx);
}
有时,我需要主动断开通道:
ChannelFuture f = channel.disconnect();
f.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) {
// the problem is the channelInactive might not be called yet
// how can I make sure channelInactive has been called?
do something but the clean-up code in channelInactive MUST be called
}
});
共 (0) 个答案