| | |
| | | if (method.equals(Method.ping)) { |
| | | String token = jsonCon.getString("token"); |
| | | String userId1 = jsonCon.getString("userId"); |
| | | String businessType = jsonCon.getString("businessType");//1:打车,2=代驾 |
| | | String business = "1".equals(businessType) ? "dache" : "daijia"; |
| | | if (StringUtil.isNotEmpty(userId1)) { |
| | | //确保账号在单个设备上登录 |
| | | if (StringUtil.isNotEmpty(token)) { |
| | | String token_ = redisUtil.getValue("USER_Applets_" + userId1);//获取缓存中最新的数据 |
| | | String token_ = redisUtil.getValue(business + ":USER_Applets_" + userId1);//获取缓存中最新的数据 |
| | | if (StringUtil.isNotEmpty(token_) && !token.equals(token_)) {//不在同一设备上登录,向其他设备发送数据 |
| | | ChannelHandlerContext data_ = NettyChannelMap.getData_(token_.substring(token_.length() - 16)); |
| | | JSONObject msg_ = new JSONObject(); |
| | |
| | | }, 5000); |
| | | } |
| | | NettyChannelMap.update_(token.substring(token.length() - 16), ctx);//存储单点登录的通道 |
| | | NettyChannelMap.update("Applets" + userId1, ctx); |
| | | redisUtil.setStrValue("USER_Applets_" + userId1, token); |
| | | NettyChannelMap.update(business + ":Applets" + userId1, ctx); |
| | | redisUtil.setStrValue(business + ":USER_Applets_" + userId1, token); |
| | | } |
| | | |
| | | //存储业务使用的通道 |
| | | if (null != ctx && ctx.channel().isActive()) { |
| | | NettyChannelMap.update("Applets" + userId1, ctx); |
| | | NettyChannelMap.update(business + ":Applets" + userId1, ctx); |
| | | } |
| | | } |
| | | |