Skip to content

Instantly share code, notes, and snippets.

@oshothebig
Created September 3, 2011 10:06
Show Gist options
  • Save oshothebig/1190949 to your computer and use it in GitHub Desktop.
Save oshothebig/1190949 to your computer and use it in GitHub Desktop.
private static class OpenFlowEncoder extends OneToOneEncoder {
@Override
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
if (msg instanceof OFMessage) {
OFMessage response = (OFMessage) msg;
// may have an bad effect on performance
ByteBuffer buffer = ByteBuffer.allocate(response.getLength());
response.writeTo(buffer);
buffer.flip();
return ChannelBuffers.wrappedBuffer(buffer);
}
return ChannelBuffers.EMPTY_BUFFER;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment