Reputation: 169
what is the difference between channelInactive and close and disconnect event in channelhandler?
If I close the channel mannually, all three methods in channelhandler will be called?
If the channel closed by network errors, all three methods in channelhandler will be called?
I wonder if I just implment the channelInactive method, does all the close and disconnect event be covered too? I means is the channelInactive method superior than others?
Upvotes: 4
Views: 2568
Reputation: 23557
The difference is that disconnect
and close
are outbound which is also why these are defined in ChannelOutboundHandler
while channelInactive
is inbound and thus is defined in ChannelInboundHandler
.
Outbound events are events that are explicit triggered via Channel.*
, ChannelHandlerContext.*
methods, like for example: "I want to close the Channel". The user can then intercept these and do something, like delay closing etc.
Inbound events are triggered by the transport itself (and so the EventLoop
) and usually tell you that something has happened (which may be because you requested it or the remote peer did so).
The difference between disconnect
and close
depend on the transport itself, for example when using TCP
there is no difference while when using UDP
there is one.
Upvotes: 6