From 73963b4d040c1addd64193ed13ebd3795ff755f1 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 08 八月 2025 10:03:10 +0800 Subject: [PATCH] 修改bug --- MessagePushTravel/src/main/java/com/sinata/push/util/applets/WebSocketHandler.java | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-) diff --git a/MessagePushTravel/src/main/java/com/sinata/push/util/applets/WebSocketHandler.java b/MessagePushTravel/src/main/java/com/sinata/push/util/applets/WebSocketHandler.java index e1086ab..9b9d62f 100644 --- a/MessagePushTravel/src/main/java/com/sinata/push/util/applets/WebSocketHandler.java +++ b/MessagePushTravel/src/main/java/com/sinata/push/util/applets/WebSocketHandler.java @@ -1,7 +1,6 @@ package com.sinata.push.util.applets; import com.alibaba.fastjson.JSONObject; -import com.sinata.push.util.SpringUtil; import com.sinata.push.util.echo.Method; import com.sinata.push.util.echo.NettyChannelMap; import com.sinata.push.util.echo.NettyMsg; @@ -16,7 +15,6 @@ import io.netty.handler.timeout.IdleState; import io.netty.handler.timeout.IdleStateEvent; import io.netty.util.CharsetUtil; -import org.springframework.data.redis.core.StringRedisTemplate; import java.util.HashMap; @@ -25,9 +23,7 @@ //用于websocket握手的处理类 private WebSocketServerHandshaker handshaker; - private static final String WEB_SOCKET_URL = "ws://localhost:8888/websocket"; - - private NettyWebSocketController nettyWebSocketController = SpringUtil.getObject(NettyWebSocketController.class); + private static final String WEB_SOCKET_URL = "ws://localhost:8808/websocket"; @@ -77,10 +73,6 @@ } private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) { - HttpHeaders headers = req.headers(); - headers.names().forEach(name -> { - System.out.println(name + ":" + headers.get(name)); - }); // Http解码失败,向服务器指定传输的协议为Upgrade:websocket if(!req.getDecoderResult().isSuccess() || !("websocket").equals(req.headers().get("Upgrade"))){ sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST)); @@ -127,8 +119,8 @@ jsonObject.put("data", new JSONObject()); TextWebSocketFrame tws = new TextWebSocketFrame(jsonObject.toJSONString()); // ctx.channel().writeAndFlush(tws); - - nettyWebSocketController.JudgeOperation(ctx,requestmsg);//小程序心跳处理 + + new NettyWebSocketController().JudgeOperation(ctx,requestmsg);//小程序心跳处理 // 群发服务端心跳响应 Global.group.writeAndFlush(new TextWebSocketFrame((tws).text())); -- Gitblit v1.7.1