ÎļþÃû´Ó ruoyi-common/src/main/java/com/ruoyi/common/websocket/util/WebSocketUtils.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.websocket.util; |
| | | package com.ruoyi.utils.websocket.util; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import javax.websocket.RemoteEndpoint; |
| | | import javax.websocket.Session; |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.*; |
| | | |
| | | /** |
| | | * @ClassName WebSocketUtils |
| | |
| | | } |
| | | } |
| | | } |
| | | public static void sendMessage(Session session, List message) { |
| | | if (session == null) { |
| | | return; |
| | | } |
| | | final RemoteEndpoint.Basic basic = session.getBasicRemote(); |
| | | if (basic == null) { |
| | | return; |
| | | } |
| | | synchronized(session) { |
| | | try { |
| | | session.getBasicRemote().sendText( String.join(", ", message)); |
| | | } catch (IOException e) { |
| | | log.error("sendMessage IOException ",e); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * æ¨éæ¶æ¯å°å
¶ä»å®¢æ·ç«¯ |
| | | * @param message |