// Copyright (C) 2015 anduo
// All rights reserved
package com.anduo.filesync.handler;
import io.netty.buffer.ByteBuf;
import io.netty.channel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ━━━━━━神兽出没━━━━━━
* ┏┓ ┏┓
* ┏┛┻━━━┛┻┓
* ┃ ┃
* ┃ ━ ┃
* ┃ ┳┛ ┗┳ ┃
* ┃ ┃
* ┃ ┻ ┃
* ┃ ┃
* ┗━┓ ┏━┛
* ┃ ┃神兽保佑, 永无BUG!
* ┃ ┃Code is far away from bug with the animal protecting
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛
* ━━━━━━感觉萌萌哒━━━━━━
* Summary: 文件接收方,处理器
* Author : anduo@qq.com
* Version: 1.0
* Date : 15/7/5
* time : 17:15
*/
public class FileMsgSendHandler extends ChannelOutboundHandlerAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(FileMsgSendHandler.class);
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
throws Exception {
LOGGER.info("发送文件啦");
ByteBuf buf = ctx.alloc().buffer();
ctx.writeAndFlush(buf, promise);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
}