public class ProtoBufServerHandler extends ChannelInboundHandlerAdapter {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg)
throws Exception {
PersonProto.Person req = (PersonProto.Person)msg;
System.out.println("get data name = "+req.getName());
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
if(cause instanceof IOException){
System.out.println("远程客户端强迫关闭了一个现有的连接。");
}
ctx.close();
}
}