/**
* {@inheritDoc}
* @see io.netty.channel.ChannelOutboundInvoker#write(java.lang.Object)
*/
@Override
public ChannelFuture write(Object message) {
if(message!=null) {
if(message instanceof FileRegion) {
try {
Pipe pipe = Pipe.open();
FileRegion fr = (FileRegion)message;
long bytesToRead = fr.count();
fr.transferTo(pipe.sink(), 0L);
byte[] content = new byte[(int)bytesToRead];
pipe.source().read(ByteBuffer.wrap(content));
channelWrites.add(content);
} catch (Exception ex) {
log.error("Failed to read content from pipe", ex);
channelWrites.add(ex);
}
} else {
channelWrites.add(message);
}
log.info("Received Channel Write [{}] type:[{}]", message, message.getClass().getName());
}
return null;
}
InvocationChannel.java 文件源码
java
阅读 42
收藏 0
点赞 0
评论 0
项目:HeliosStreams
作者:
评论列表
文章目录