Skip to content

Instantly share code, notes, and snippets.

@lennartkoopmann
Created April 16, 2012 12:40
Show Gist options
  • Save lennartkoopmann/2398518 to your computer and use it in GitHub Desktop.
Save lennartkoopmann/2398518 to your computer and use it in GitHub Desktop.
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
byte[] readable = new byte[buffer.readableBytes()];
buffer.toByteBuffer().get(readable, 0, buffer.readableBytes()); // I'm 12 years old and what is this? There must be a better way.
GELFMessage msg = new GELFMessage(readable);
if (msg.getGELFType() == GELFMessage.TYPE_CHUNKED) {
// This is a GELF message chunk. Add chunk to manager.
server.getGELFChunkManager().insert(msg.asChunk()); // XXX IMPROVE: this msg.asChunk() is a bit bumpy. better have a chunk from the beginning on.
} else {
// This is a non-chunked/complete GELF message. Process it.
processor.messageReceived(msg);
}
return buffer.readBytes(buffer.readableBytes());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment