Frame frame = (Frame)msg;
ChannelBuffer header = ChannelBuffers.buffer(Frame.Header.LENGTH);
// We don't bother with the direction, we only send requests.
header.writeByte(frame.header.version);
header.writeByte(Header.Flag.serialize(frame.header.flags));
header.writeByte(frame.header.streamId);
header.writeByte(frame.header.opcode);
header.writeInt(frame.body.readableBytes());
return ChannelBuffers.wrappedBuffer(header, frame.body);