get timer instance from ReadTimeoutHandler subclasses

"Trustin Lee (이희승)" trustin at gmail.com
Wed Mar 24 02:10:21 EDT 2010


谢非 wrote:
> if the  timer is started implicitly and shared ,  what is the start point
> for an individual connection?
> channelOpened?

It's channelConnected().  Before channelConnected, there are channelOpen
and channelBound, but there's no guarantee that the connection has been
established there.

> Or can I use one timer for each connection to achieve a more accurate start
> point control?

You can call timer.start() in channelConnected() if you really want.  My
point was that it's not very efficient since the call will be only
effective on the first call.

HTH,
Trustin

> 2010/3/24 "Trustin Lee (이희승)" <trustin at gmail.com>
> 
>> Timer is shared by many connections, and therefore it's not efficient to
>> call Timer.start() in channelConnected().  If you want to start the
>> timer thread explicitly before communication starts, you'd better call
>> Timer.start() before calling ServerBootstrap.bind() or
>> ClientBootstrap.connect().
>>
>> HTH,
>> Trustin
>>
>> 谢非 wrote:
>>> hi all,
>>>
>>>     I need to start the timeout timer in channelConnected() event handler
>> of
>>> a ReadTimeoutHandler subclass, but it seems that there is no protected
>>> getTimer() in ReadTimeoutHandler.
>>>     should I store the timer as a member field like this:
>>>
>>>       class ServerReadTimeoutHandler extends ReadTimeoutHandler {
>>>              Timer timer;
>>>
>>>              public ServerReadTimeoutHandler(Timer timer, int
>>> timeoutSeconds) {
>>>                          super(timer, timeoutSeconds);
>>>                           this.timer = timer;
>>>              }
>>>
>>>             @Override
>>>             public void channelConnected(ChannelHandlerContext ctx,
>>> ChannelStateEvent e) throws Exception {
>>>                  timer.start();
>>>                  super.channelConnected(ctx, e);
>>>             }
>>>      }
>>>
>>> Centaur
>>> 20100318
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> netty-users mailing list
>>> netty-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/netty-users
>> --
>> what we call human nature in actuality is human habit
>> http://gleamynode.net/
>>
>>
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100324/34896e8b/attachment-0001.bin 


More information about the netty-users mailing list