liujie
2025-08-05 6a78f6662534214f836dfb7ffa7d6b55dc0353ab
MessagePushTravel/src/main/java/com/sinata/push/util/echo/DiscardServerHandler.java
@@ -1,5 +1,6 @@
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;
@@ -7,13 +8,14 @@
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 = new NettyServerController();
   private NettyServerController nettyServerController = SpringUtil.getObject(NettyServerController.class);
   
   public static boolean isdebug = true;
@@ -21,7 +23,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
@@ -37,7 +39,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
@@ -68,7 +70,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......");
      }
   }