Skip to content

Instantly share code, notes, and snippets.

@daschl
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daschl/9205337 to your computer and use it in GitHub Desktop.
Save daschl/9205337 to your computer and use it in GitHub Desktop.
Flush me maybe!
/**
* Helper method to flush the pipeline if possible.
*
* Hey, I just connected you,
* And this is crazy,
* But here's my data,
* So flush me maybe!
* It's hard to read right,
* From your channel,
* But here's my data,
* So flush me maybe!
*
* @param ctx the channel handler context.
*/
private static void flushMeMaybe(final ChannelHandlerContext ctx) {
Channel channel = ctx.channel();
if (channel.isWritable() && channel.isActive()) {
ctx.flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment