android - Netty websocket close gracefully -


i need make websocket close gracefully. firstly send messages waiting in buffer close.

channel.flush(); channel.close(); 

seems not right, because dont have completion handler flush method close after done.

is there way this. netty used: 4.1.0.beta3

the trick can use writeandflush empty buffer, attach listener call. unpooled.empty_buffer can make pretty easy.

channel.writeandflush(unpooled.empty_buffer).addlistener(...     channel.close(); )}; 

if want close channel after flush can use channelfuturelistener.close simplify code.

channel.writeandflush(unpooled.empty_buffer).addlistener(channelfuturelistener.close); 

if enough, may want write static helper method like netty examples do.


Comments

Popular posts from this blog

sql - can we replace full join with union of left and right join? why not? -

javascript - Parallax scrolling and fixed footer code causing width issues -

iOS: Performance of reloading UIImage(name:...) -