ChannelFuture.await() and ChannelFutureListener.operationComplete()

hezjing hezjing at gmail.com
Fri Apr 3 23:55:31 EDT 2009


Hi
I'm following the Writing a Time
Server<http://www.jboss.org/file-access/default/members/netty/freezone/guide/3.1/html_single/index.html#d0e489>
chapter
of Netty 3.1 user's guide.

Here is the code snippet to close the connection after a message is written
successfully:

ChannelFuture f = ch.write(time);
f.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) {
Channel ch = future.getChannel();
ch.close();
}
});


I think the above code can also be simplified to the following (?):

ChannelFuture f = ch.write(time);
f.await();
ch.close();


Am I correct to say that both approaches are identical?


-- 

Hez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20090404/9a0986f6/attachment.html 


More information about the netty-users mailing list