How to control the Channel out of Handler object

Thomas Bocek bocek at ifi.uzh.ch
Wed Sep 16 04:49:38 EDT 2009


Hmm, it should work both ways, using await and addListener(), if await
is not working, then I think its a bug in Netty. I my opinion the
WriteFuture should get notified always after issuing a write(),
regardless if it the channel gets closed or a client gets disconnected.

Thomas

Michael McGrady wrote:
> I think you want something like the following:
> 
> DefaultHttpChunk chunk = new DefaultHttpChunk(buf);
> 
> ChannelFuture future = e.getChannel().write(chunk);
> 
> future.addListener(new ChannelFutureListener() {
> 
> public void operationComplete(ChannelFuture future) {
> if (future.isSuccess()) {
> } else {
> }
> }
> 
> });
> On Sep 15, 2009, at 10:56 AM, olekg wrote:
> 
>>
>> Hello,
>>
>> As I written in another thread I try to build Comet/Streaming solution
>> with
>> Netty. I have partialy chieved me goal for one-client connection.
>>
>> The idea for my application is to run timer in singleton object which
>> updates all registered Event objects, registered in HttpRequestHandler. In
>> other words when obtain messageReceived event I do not build the response.
>> Instead I pass the Event object to be many times used to fill client with
>> data.
>>
>> Unofortuanately I have lost the control over transmission erreors. I have
>> the code :
>>
>>       DefaultHttpChunk chunk = new DefaultHttpChunk( buf);
>>       ChannelFuture chf = e.getChannel().write(chunk);
>>       if ( chf.isSuccess() ) {
>>       System.out.println("Wyprowadzono porcję skryptu przez kanał.");
>>       
>>       } else {
>>       System.out.println("Error");
>>       Throwable thr = chf.getCause();
>>       if( thr != null ) {
>>       System.out.println( thr.getMessage());
>>       } else {
>>       System.out.println("Null error object.");
>>       
>>       }
>>       
>>       }
>>
>> Regardless of the data is sent correctly or not I malway obtain "Error"
>> message and "Null error object". I want to know when client discnnects.
>>
>> When I am inside HttpRequestHandler the exceptionCaught event is fired
>> correctly. What if I am outside ?
>>
>> regards Olek
>> -- 
>> View this message in context:
>> http://n2.nabble.com/How-to-control-the-Channel-out-of-Handler-object-tp3650670p3650670.html
>> Sent from the Netty User Group mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org <mailto:netty-users at lists.jboss.org>
>> https://lists.jboss.org/mailman/listinfo/netty-users
> 
> Mike McGrady
> Principal Investigator AF081-028 AFRL SBIR
> Senior Engineer
> Topia Technology, Inc
> 1.253.720.3365
> mmcgrady at topiatechnology.com <mailto:mmcgrady at topiatechnology.com>
> 
> 
> 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users

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


More information about the netty-users mailing list