Pu Zhibing
2025-08-05 b85d1d0b0a33190fc820adf4af45f98499b274cf
MessagePushTravel/src/main/java/com/sinata/push/util/applets/WebSocketHandler.java
@@ -27,7 +27,7 @@
    private static final String WEB_SOCKET_URL = "ws://localhost:8888/websocket";
    
    private NettyWebSocketController nettyWebSocketController = SpringUtil.getObject(NettyWebSocketController.class);
//    private NettyWebSocketController nettyWebSocketController = SpringUtil.getObject(NettyWebSocketController.class);
@@ -123,18 +123,21 @@
        //给连接的客户端返回数据
        //返回心跳
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", 200);
        jsonObject.put("method", Method.ok);
        jsonObject.put("msg", "SUCCESS");
        jsonObject.put("data", new JSONObject());
        TextWebSocketFrame tws = new TextWebSocketFrame(jsonObject.toJSONString());
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("code", 200);
//        jsonObject.put("method", Method.ok);
//        jsonObject.put("msg", "SUCCESS");
//        jsonObject.put("data", new JSONObject());
//        TextWebSocketFrame tws = new TextWebSocketFrame(jsonObject.toJSONString());
//        ctx.channel().writeAndFlush(tws);
        String s = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>());
        ctx.writeAndFlush(Unpooled.copiedBuffer((s).getBytes()));
    
        nettyWebSocketController.JudgeOperation(ctx,requestmsg);//小程序心跳处理
//        nettyWebSocketController.JudgeOperation(ctx,requestmsg);//小程序心跳处理
        // 群发服务端心跳响应
        Global.group.writeAndFlush(new TextWebSocketFrame((tws).text()));
//        Global.group.writeAndFlush(new TextWebSocketFrame((tws).text()));
    }
    private void sendHttpResponse(ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res) {