public class Response{
public int packetLength;
public int cmd;
public int seqId;
public FileRegion fileRegion; //file content
public String filename;
public int begin;
public int end;
public String otherExtra;
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e){
if(e.getMessage() instanceof Request){
Request request = Request(e.getMessage());
Channel ch = e.getChannel();
Response response = new Response();
response.cmd = 111;
response.seqId = 111;
response.begin = 0;
response.end = 256;
response.fileRegion = new DefaultFileRegion(GetFile().getChannel(),response.begin, response.end);
response.filename = "test";
response.otherExtra = "service"
ch.write(response);
}
}
}
I need to use zero-copy (os level) to send data in a field of a network packet. netty support FileRegion and ChannelBuffer in these two types of data transmission. But now I want these two kinds of types of data together to form a packet.
How to solve Or how to write the above code encoder function?