From 1c40baaf9ca0183945b9881d11ceed5aeebc8290 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 23 十月 2025 11:35:44 +0800
Subject: [PATCH] 修改bug
---
MessagePushTravel/src/main/java/com/sinata/push/util/echo/DiscardServerHandler.java | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/MessagePushTravel/src/main/java/com/sinata/push/util/echo/DiscardServerHandler.java b/MessagePushTravel/src/main/java/com/sinata/push/util/echo/DiscardServerHandler.java
index 595c397..c0351a9 100644
--- a/MessagePushTravel/src/main/java/com/sinata/push/util/echo/DiscardServerHandler.java
+++ b/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......");
}
}
@@ -92,7 +90,7 @@
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);
}
}
}
@@ -103,11 +101,11 @@
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);
+ super.channelInactive(ctx);
}
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
--
Gitblit v1.7.1