Pu Zhibing
2024-12-24 905eb707fff6fc6702c1c9e8333520012dd89414
ZuulAHTravel/src/main/java/com/sinata/zuul/util/applets/NettyWebSocketController.java
@@ -82,30 +82,30 @@
                String userId1 = jsonCon.getString("userId");
                if (StringUtil.isNotEmpty(userId1)) {
                    //确保账号在单个设备上登录
                    if (StringUtil.isNotEmpty(token)) {
                        NettyChannelMap.update_(token.substring(0, 23), ctx);//存储单点登录的通道
                        String token_ = redisUtil.getValue("USER_Applets_" + userId1);//获取缓存中最新的数据
                        if (StringUtil.isNotEmpty(token_) && !token.equals(token_)) {//不在同一设备上登录,向其他设备发送数据
                            JSONObject msg_ = new JSONObject();
                            msg_.put("code", 200);
                            msg_.put("msg", "SUCCESS");
                            msg_.put("method", "OFFLINE");
                            msg_.put("data", new Object());
                            this.sendMsgToClient(ctx, msg_.toJSONString());
                            TimerTask timerTask = new TimerTask() {
                                @Override
                                public void run() {
                                    NettyChannelMap.remove_(ctx);
                                }
                            };
                            Timer timer = new Timer();
                            timer.schedule(timerTask, 3000);
                            timer.cancel();
                        }
                        if (StringUtil.isEmpty(token_)) {//确保登录的时候存储token失败的情况
                            redisUtil.setStrValue("USER_Applets_" + userId1, token);
                        }
                    }
//                    if (StringUtil.isNotEmpty(token)) {
//                        NettyChannelMap.update_(token.substring(0, 23), ctx);//存储单点登录的通道
//                        String token_ = redisUtil.getValue("USER_Applets_" + userId1);//获取缓存中最新的数据
//                        if (StringUtil.isNotEmpty(token_) && !token.equals(token_)) {//不在同一设备上登录,向其他设备发送数据
//                            JSONObject msg_ = new JSONObject();
//                            msg_.put("code", 200);
//                            msg_.put("msg", "SUCCESS");
//                            msg_.put("method", "OFFLINE");
//                            msg_.put("data", new Object());
//                            this.sendMsgToClient(ctx, msg_.toJSONString());
//                            TimerTask timerTask = new TimerTask() {
//                                @Override
//                                public void run() {
//                                    NettyChannelMap.remove_(ctx);
//                                }
//                            };
//                            Timer timer = new Timer();
//                            timer.schedule(timerTask, 3000);
//                            timer.cancel();
//                        }
//                        if (StringUtil.isEmpty(token_)) {//确保登录的时候存储token失败的情况
//                            redisUtil.setStrValue("USER_Applets_" + userId1, token);
//                        }
//                    }
                    //存储业务使用的通道
                    if (null != ctx && ctx.channel().isActive()) {