Pu Zhibing
2025-08-05 4872bb7719c4ccaaab99438af3d987787c818c2a
MessagePushTravel/src/main/java/com/sinata/push/util/echo/DiscardServerHandler.java
@@ -1,6 +1,5 @@
package com.sinata.push.util.echo;
import com.sinata.push.util.SpringUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
@@ -8,14 +7,13 @@
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.util.ReferenceCountUtil;
import org.springframework.data.redis.core.RedisTemplate;
import java.net.InetSocketAddress;
import java.util.HashMap;
public class DiscardServerHandler extends SimpleChannelInboundHandler<String>  {
   private NettyServerController nettyServerController = SpringUtil.getObject(NettyServerController.class);
   private NettyServerController nettyServerController = new NettyServerController();
   
   public static boolean isdebug = true;
@@ -23,7 +21,7 @@
   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
@@ -39,7 +37,7 @@
   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
@@ -70,7 +68,7 @@
   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......");
      }
   }
@@ -106,7 +104,7 @@
//         System.err.println(insocket.getAddress() + ": Disconnect connection......");
      }
      NettyChannelMap.remove(ctx);
      System.err.println("清除通道" + ctx);
//      System.err.println("清除通道" + ctx);
//      super.channelInactive(ctx);
   }