09-10-netty优化
This commit is contained in:
@ -145,7 +145,7 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
|
||||
roomCounts.put(loginUser.getUserId()+"+"+chatGroup.getId().toString(), list.size());
|
||||
}
|
||||
//在遍历的同时寻找是否有系统消息房间
|
||||
if (chatGroup.getMembers().contains("system")){
|
||||
if (chatGroup.getMembers().contains("[99")){
|
||||
isHaveSystemRoom = true;
|
||||
}
|
||||
}
|
||||
@ -159,8 +159,9 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
|
||||
if (!isHaveSystemRoom){
|
||||
ChatGroup chatGroup = new ChatGroup();
|
||||
chatGroup.setType(String.valueOf(0));
|
||||
chatGroup.setMembers("[system, "+loginUser.getUserId()+"]");
|
||||
chatGroup.setMembers("[99, "+loginUser.getUserId()+"]");
|
||||
chatGroupService.save(chatGroup);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -272,7 +273,7 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
|
||||
temp.put(value,userRoomCountMap.get(value));
|
||||
}
|
||||
});
|
||||
jsonObject.put("countValue", JsonUtils.toJsonString(temp));
|
||||
jsonObject.put("unReadCount", JsonUtils.toJsonString(temp));
|
||||
//给每个通道发送对应消息
|
||||
for (ChannelHandlerContext handlerContext : channelHandlerContexts) {
|
||||
sendMessage(handlerContext, jsonObject.toString());
|
||||
@ -361,13 +362,13 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
|
||||
|
||||
//生成系统消息的聊天记录
|
||||
LambdaQueryWrapper<ChatGroup> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ChatGroup::getMembers,"[system, "+userId+"]");
|
||||
lambdaQueryWrapper.eq(ChatGroup::getMembers,"[99, "+userId+"]");
|
||||
ChatGroup groupServiceOne = chatGroupService.getOne(lambdaQueryWrapper);
|
||||
//如果给成员发送系统消息 而该成员还没有建立过连接从而没有群聊房间 则创建该成员系统消息房间
|
||||
if (groupServiceOne == null){
|
||||
groupServiceOne = new ChatGroup();
|
||||
groupServiceOne.setType(String.valueOf(0));
|
||||
groupServiceOne.setMembers("[system, "+userId+"]");
|
||||
groupServiceOne.setMembers("[99, "+userId+"]");
|
||||
chatGroupService.save(groupServiceOne);
|
||||
}
|
||||
ChatHistory chatHistory = new ChatHistory();
|
||||
@ -400,7 +401,7 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
|
||||
temp.put(value,userRoomCountMap.get(value));
|
||||
}
|
||||
});
|
||||
jsonObject.put("countValue", temp);
|
||||
jsonObject.put("unReadCount", temp);
|
||||
sendMessage(handlerContext, jsonObject.toString());
|
||||
}
|
||||
}
|
||||
|
@ -153,6 +153,9 @@ public class ChatGroupController {
|
||||
if (sysUserVo != null) {
|
||||
byId.setName(sysUserVo.getNickName());
|
||||
byId.setAvatar(sysUserVo.getAvatar());
|
||||
}else if (list.getFirst().equals(99L)){
|
||||
byId.setName("系统消息");
|
||||
byId.setAvatar(null);
|
||||
}else{
|
||||
byId.setName("此用户已注销");
|
||||
byId.setAvatar(null);
|
||||
|
Reference in New Issue
Block a user