Reputation: 1563
According to the Netty guide: http://static.netty.io/3.5/guide/#start.12
To keep track of open sockets, you need to modify the TimeServerHandler to add a new open Channel to the global ChannelGroup, TimeServer.allChannels:
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) {
TimeServer.allChannels.add(e.getChannel());
}
I implemented channelOpen
on my business logic handler. I don't see it called when a new client makes a connection. Can anyone say in detail when channelOpen
is called?
Also, can I write an upstream handler to be inserted before the ExecutionHandler
and expect channelOpen
to be called at the appropriate time, or does one have to implement channelOpen
on the business logic handler?
I'd like to be able to implement channelOpen
separately from the business logic handler if possible.
Upvotes: 1
Views: 645
Reputation: 23567
The events comes in, in this order:
channelOpen(..), channelBound(..), channelConnected(..)
...
cannelDisconnected(..), channelUnbound(..), channelClosed(..)
So channelOpen(..) should be called as first thing when a client connects..
Upvotes: 3