public class FileServerHandler extends SimpleChannelInboundHandler<ByteBuf> {
private Logger logger; private String currentFileName;
private String currentDirectory;
private long currentFileOffset;
private long currentFileChunkSize;
private boolean isDirectory;
public FileServerHandler() {
logger = Logger.getLogger(this.getClass().getName());
}
public void channelActive(ChannelHandlerContext ctx) throws Exception{
logger.info("Server:channel is active ");
}
@Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
logger.info("Server:channelRead0: filePath = " + msg);
processFileRequest(msg); //Obtains the file or directory to retrieve and the size of the file or
//files within a directory to retrieve recursively
/*
At this point I wish to tell the other channels the file or directory to retrieve, the file size, and the portion of the file(s) it should send? How can I do this? Also, if I implemented a channelManager, How can I pass this information to the channelManager and have it write the data to each channel?
*/
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
if (ctx.channel().isActive()) {
ctx.writeAndFlush("ERR: " +
cause.getClass().getSimpleName() + ": " +
cause.getMessage() + '\n').addListener(ChannelFutureListener.CLOSE);
}
}
}
--
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 netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/d499d1de-f373-43c4-a493-69f86de57a9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/120b5214-bcb3-48bb-8116-9a019bc53a7d%40googlegroups.com.
final Promise<Channel> promise = ctx.executor().newPromise();
promise.addListener(new FutureListener<Channel>() {
public void operationComplete(final Future<Channel> future) throws Exception {
// ready to start doing something now
if (future.isSuccess()) {
// go get the data
} else {
// wait failed, clean up
}
});
MyDispatcher.registerDataRequest(promise, "some data");
--
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 netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/9ce5db8b-282a-4c5f-9ccd-8fcb9ad68cd1%40googlegroups.com.