| | |
| | | public void channelRead(ChannelHandlerContext ctx, Object msg) { |
| | | InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | if(isdebug) { |
| | | // System.err.println(insocket.getAddress() + ": 收到客户端数据......."); |
| | | System.err.println(insocket.getAddress() + ": 收到客户端数据......."); |
| | | } |
| | | try { |
| | | // 调用service |
| | |
| | | protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { |
| | | InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | if(isdebug) { |
| | | // System.err.println(insocket.getAddress() + ": 收到客户端数据......."); |
| | | System.err.println(insocket.getAddress() + ": 收到客户端数据......."); |
| | | } |
| | | try { |
| | | // 调用service |
| | |
| | | public void channelActive(final ChannelHandlerContext ctx) throws Exception { |
| | | InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | if(isdebug) { |
| | | // System.err.println(insocket.getAddress() + ": Connect successful......"); |
| | | System.err.println(insocket.getAddress() + ": Connect successful......"); |
| | | } |
| | | } |
| | | |
| | |
| | | String msg = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>()); |
| | | if(ctx != null && ctx.channel().isActive()) { |
| | | ctx.writeAndFlush(Unpooled.copiedBuffer((msg).getBytes())); |
| | | // System.err.println(msg); |
| | | System.err.println(msg); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void channelInactive(ChannelHandlerContext ctx) throws Exception { |
| | | if(isdebug) { |
| | | InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress(); |
| | | // System.err.println(insocket.getAddress() + ": Disconnect connection......"); |
| | | System.err.println(insocket.getAddress() + ": Disconnect connection......"); |
| | | } |
| | | NettyChannelMap.remove(ctx); |
| | | // System.err.println("清除通道" + ctx); |
| | | // super.channelInactive(ctx); |
| | | System.err.println("清除通道" + ctx); |
| | | super.channelInactive(ctx); |
| | | } |
| | | |
| | | public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { |