判断wsurl 不为空

pull/3/head
liuhanqing 2021-02-01 22:33:56 +08:00
parent b3da7f3139
commit c08308a7d4
1 changed files with 10 additions and 5 deletions

View File

@ -76,10 +76,15 @@ public class WebSocketManager {
* @date 2021/1/24 22:11 * @date 2021/1/24 22:11
*/ */
public static void sendMessage(Long userId, String message) { public static void sendMessage(Long userId, String message) {
for(Session userSession: getSessionByUserId(userId)){ List<Session> sessionList = getSessionByUserId(userId);
// 增加判断不为空
if (!CollectionUtils.isEmpty(sessionList)) {
for (Session userSession : sessionList) {
userSession.getAsyncRemote().sendText(message); userSession.getAsyncRemote().sendText(message);
} }
} }
}
/** /**
* *
* *