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

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -