From 73b750200f25df08aa64124da49e7461f9de6653 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 13 十二月 2024 15:09:49 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/NTTravel

---
 ZuulNTTravel/src/main/java/com/sinata/zuul/util/echo/NettyServerController.java |   97 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 65 insertions(+), 32 deletions(-)

diff --git a/ZuulNTTravel/src/main/java/com/sinata/zuul/util/echo/NettyServerController.java b/ZuulNTTravel/src/main/java/com/sinata/zuul/util/echo/NettyServerController.java
index 979b6a4..ade75b1 100644
--- a/ZuulNTTravel/src/main/java/com/sinata/zuul/util/echo/NettyServerController.java
+++ b/ZuulNTTravel/src/main/java/com/sinata/zuul/util/echo/NettyServerController.java
@@ -191,39 +191,72 @@
 
 
                         //确保账号在单个设备上登录
+//						String value = redisUtil.getValue("DEVICE_" + userId1);
+//						if(StringUtil.isNotEmpty(token) && StringUtil.isEmpty(device) && StringUtil.isEmpty(value)){//APP端登录的操作
+//                            String token_ = redisUtil.getValue("DRIVER_" + userId1);//缓存中拿最新数据
+//                            if(StringUtil.isNotEmpty(token_) && !token.equals(token_)){//不在同一设备上登录,向当前设备发送数据
+//                                ChannelHandlerContext data_ = NettyChannelMap.getData_(token_.substring(0, 23));
+//
+//                                JSONObject msg_ = new JSONObject();
+//                                msg_.put("code", 200);
+//                                msg_.put("msg", "SUCCESS");
+//                                msg_.put("method", "OFFLINE");
+//                                msg_.put("data", new Object());
+//								this.sendMsgToClient(data_, msg_.toJSONString());//给当前通道发送消息
+//                                TimerTask timerTask = new TimerTask() {
+//                                    @Override
+//                                    public void run() {
+//                                        NettyChannelMap.remove_(data_);
+//										NettyChannelMap.remove(data_);
+//                                    }
+//                                };
+//                                Timer timer = new Timer();
+//                                timer.schedule(timerTask, 3000);
+//                                timer.cancel();
+//                            }
+//
+//                            NettyChannelMap.update("DRIVER" + userId1, ctx);
+//                            NettyChannelMap.update_(token.substring(0, 23), ctx);
+//                            String s = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>());
+//                            ctx.writeAndFlush(Unpooled.copiedBuffer((s).getBytes()));
+//
+//                            if(StringUtil.isEmpty(token_)){//确保登录的时候存储token失败的情况
+//                                redisUtil.setStrValue("DRIVER_" + userId1, token);
+//                            }
+//                        }
+
+						//确保账号在单个设备上登录
 						String value = redisUtil.getValue("DEVICE_" + userId1);
-						if(StringUtil.isNotEmpty(token) && StringUtil.isEmpty(device) && StringUtil.isEmpty(value)){//APP端登录的操作
-                            String token_ = redisUtil.getValue("DRIVER_" + userId1);//缓存中拿最新数据
-                            if(StringUtil.isNotEmpty(token_) && !token.equals(token_)){//不在同一设备上登录,向当前设备发送数据
-                                ChannelHandlerContext data_ = NettyChannelMap.getData_(token_.substring(0, 23));
-
-                                JSONObject msg_ = new JSONObject();
-                                msg_.put("code", 200);
-                                msg_.put("msg", "SUCCESS");
-                                msg_.put("method", "OFFLINE");
-                                msg_.put("data", new Object());
-								this.sendMsgToClient(data_, msg_.toJSONString());//给当前通道发送消息
-                                TimerTask timerTask = new TimerTask() {
-                                    @Override
-                                    public void run() {
-                                        NettyChannelMap.remove_(data_);
-										NettyChannelMap.remove(data_);
-                                    }
-                                };
-                                Timer timer = new Timer();
-                                timer.schedule(timerTask, 3000);
-                                timer.cancel();
-                            }
-
-                            NettyChannelMap.update("DRIVER" + userId1, ctx);
-                            NettyChannelMap.update_(token.substring(0, 23), ctx);
-                            String s = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>());
-                            ctx.writeAndFlush(Unpooled.copiedBuffer((s).getBytes()));
-
-                            if(StringUtil.isEmpty(token_)){//确保登录的时候存储token失败的情况
-                                redisUtil.setStrValue("DRIVER_" + userId1, token);
-                            }
-                        }
+						if(StringUtil.isNotEmpty(token) && StringUtil.isEmpty(value)){//APP端登录的操作
+							String token_ = redisUtil.getValue("DRIVER_" + 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);
+										NettyChannelMap.remove(ctx);
+									}
+								};
+								Timer timer = new Timer();
+								timer.schedule(timerTask, 3000);
+								timer.cancel();
+							}else{
+//                                                                System.err.println("开始存储司机通道" + userId1);
+								NettyChannelMap.update("DRIVER" + userId1, ctx);
+								NettyChannelMap.update_(token.substring(0, 23), ctx);
+								String s = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>());
+								ctx.writeAndFlush(Unpooled.copiedBuffer((s).getBytes()));
+							}
+							if(StringUtil.isEmpty(token_)){//确保登录的时候存储token失败的情况
+								redisUtil.setStrValue("DRIVER_" + userId1, token);
+							}
+						}
 
 
                         //存储通讯通道

--
Gitblit v1.7.1