I am implementing a client that will receive a single file from the server. To keep it simple, I am assuming the client already knows the name of the file it is to receive. So the client will first receive a file header followed by actual file contents. The header is simple, just the length of the file encapsulated as an 8 byte long.
*Overall Sequence Diagram* *Server* --> Length of File --> *Client* *Server* --> FileContents --> *Client* I add the following channel handlers to my client’s channel handler pipeline: *p.addLast(new msgToLongDecoder(), chunkedReadHandler()); * where msgToLongDecoder extends ByteToMessageDecoder and ReadFileHandler ReadFileHandler extends SimpleChannelInboundHandler *New Overall Sequence Diagram* *Server* --> Length of File --> *Client*(MsgToLongDecoder ReadFileHandler) *Server* --> FileContents --> *Client*(MsgToLongDecoderReadFileHandler) After the client receives the file length (encapsulated by raw bytes) the client first uses the MsgToLongDecoder to decode the bytes ( into the file length (type Long). *Questions* 1. After decoding, is the file length automatically pushed to the next handler in the channel pipeline which will be the ReadFileHandler? if so, what method in the netty code would automatically push the file Length to the next handler? 2. Also do I have to manually within the code handle this case, meaning within the readFileHandler methos I will have to check to see if the event/msg is an instance of ByteBuf () as in (if message instanceof ByteBuf)? 3. *When the server sends the actual file contents, based on the channel pipeline, will the client’s msgToLongDecoder first receive the file contents (ByteBuf)? if so, does the msgToLongDecoder automatically ignore the stream and pushes it to the next channelHandler within the pipeline which is the ReadFileHandler? Or do I have to manually do this?* Also, how can the ReadFileHandler accept and process ChunkedInput? The Netty API specifies that ChunkedInput is a data stream of indefinite length which is consumed by *ChunkedWriteHandler*? -- You received this message because you are subscribed to the Google Groups "Netty discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/netty/1c04e386-0bbb-4b2c-87b4-c9f82dd2cc11%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
