查询省市
会员关联 桌码绑定新的 旧的清除
This commit is contained in:
@@ -65,6 +65,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
log.info("netty连接 长连接激活");
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
@@ -113,7 +114,6 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, String msg) {
|
||||
log.info("netty连接 接收到数据:{}",msg);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (StringUtils.isNotEmpty(msg)) {
|
||||
jsonObject = JSONObject.parseObject(msg);
|
||||
@@ -122,7 +122,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
||||
}
|
||||
String type = jsonObject.getString("type");
|
||||
if(type.equals("heartbeat")){//心跳
|
||||
log.info("netty连接 接收到数据:tableId:{} meg:{}",tableId,msg);
|
||||
log.info("netty连接 接收到心跳数据:tableId:{} meg:{}",tableId,msg);
|
||||
}else {
|
||||
if (type.equals("connect")) {
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
@@ -139,10 +139,10 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
||||
this.shopId=shopId;
|
||||
if (webSocketMap.containsKey(key)) {
|
||||
ConcurrentHashMap<String, ChannelHandlerContext> userSocketMap = webSocketMap.get(key);
|
||||
// ChannelHandlerContext channelHandlerContext = userSocketMap.get(userId);
|
||||
// if (channelHandlerContext != null) {
|
||||
// channelHandlerContext.close();
|
||||
// }
|
||||
ChannelHandlerContext channelHandlerContext = userSocketMap.get(userId);
|
||||
if (channelHandlerContext != null) {
|
||||
channelHandlerContext.close();
|
||||
}
|
||||
userSocketMap.put(userId, ctx);
|
||||
} else {
|
||||
ConcurrentHashMap<String, ChannelHandlerContext> userSocketMap = new ConcurrentHashMap<>();
|
||||
@@ -160,6 +160,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
||||
rabbitProducer.putCart(jsonObject.toJSONString());
|
||||
}
|
||||
else{
|
||||
log.info("netty连接 接收到接口数据:meg:{}",msg);
|
||||
jsonObject.put("tableId", this.tableId);
|
||||
jsonObject.put("shopId", this.shopId);
|
||||
if("sku".equals(type)){
|
||||
@@ -222,9 +223,17 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
||||
} else if (webSocketMap.containsKey(tableId)) {
|
||||
ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(tableId);
|
||||
if(!webSockets.isEmpty()) {
|
||||
for (ChannelHandlerContext ctx : webSockets.values()) {
|
||||
sendMesToApp(message,ctx);
|
||||
for (String user : webSockets.keySet()) {
|
||||
ChannelHandlerContext ctx = webSockets.get(user);
|
||||
if (ctx != null) {
|
||||
log.info("netty连接 发送消息 桌码群发 userId:{}",user);
|
||||
sendMesToApp(message,ctx);
|
||||
}else {
|
||||
log.info("netty连接 发送消息 桌码群发 userId:{} 失败",user);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
log.info("netty连接 发送消息 桌码群发 tableId:{} 失败",tableId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user