private void flushMessages(final ChannelHandlerContext ctx, final SockJsSession session) {
final String[] allMessages = session.getAllMessages();
if (allMessages.length == 0) {
return;
}
final MessageFrame messageFrame = new MessageFrame(allMessages);
ChannelFuture channelFuture = ctx.channel().writeAndFlush(messageFrame);
channelFuture.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(final ChannelFuture future) throws Exception {
if (!future.isSuccess()) {