diff --git a/src/main/java/com/sqx/modules/chat/controller/app/AppChatSocket.java b/src/main/java/com/sqx/modules/chat/controller/app/AppChatSocket.java index 45b47e4..de88980 100644 --- a/src/main/java/com/sqx/modules/chat/controller/app/AppChatSocket.java +++ b/src/main/java/com/sqx/modules/chat/controller/app/AppChatSocket.java @@ -35,8 +35,6 @@ public class AppChatSocket {//用户聊天 */ private static Map clients = new ConcurrentHashMap(); - private static Map sessionMap = new ConcurrentHashMap(); - private static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); /** * 会话 @@ -80,7 +78,6 @@ public class AppChatSocket {//用户聊天 clients.remove(userId); } clients.put(userId, this); - sessionMap.put(userId,session); /*sendMessageTo("恭喜你连接成功!",wxUserId);*/ } @@ -143,9 +140,9 @@ public class AppChatSocket {//用户聊天 // } List toUsers = chatContentService.selectUserByConversationId(Long.parseLong(chatConversationId)); for(ChatContent toUser :toUsers){ - Session userSession = sessionMap.get(toUser.getUserId()); - if (userSession!=null) { - userSession.getAsyncRemote().sendText(message); + AppChatSocket chatSocket = clients.get(toUser.getUserId()); + if (chatSocket!=null) { + chatSocket.session.getAsyncRemote().sendText(message); System.err.println(this.userId+"发送成功:"+userId); } }