From 4ed693f48d1435de7a6333df17c2b34154731429 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期三, 05 七月 2023 22:26:27 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity

---
 service-api/src/main/java/com/java110/api/websocket/ParkingAreaWebsocket.java |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/service-api/src/main/java/com/java110/api/websocket/ParkingAreaWebsocket.java b/service-api/src/main/java/com/java110/api/websocket/ParkingAreaWebsocket.java
index 962e3de..1e0dfe5 100644
--- a/service-api/src/main/java/com/java110/api/websocket/ParkingAreaWebsocket.java
+++ b/service-api/src/main/java/com/java110/api/websocket/ParkingAreaWebsocket.java
@@ -22,7 +22,7 @@
  * @Version 1.0
  * add by wuxw 2020/5/25
  **/
-@ServerEndpoint("/ws/parkingArea/{boxId}/{clientId}")
+@ServerEndpoint("/ws/parkingArea/{paId}/{clientId}")
 @Component
 public class ParkingAreaWebsocket {
 
@@ -50,16 +50,16 @@
      */
     private String clientId = "";
 
-    private String boxId = "";
+    private String paId = "";
 
     /**
      * 杩炴帴寤虹珛鎴愬姛璋冪敤鐨勬柟娉�
      */
     @OnOpen
-    public void onOpen(Session session, @PathParam("clientId") String clientId, @PathParam("boxId") String boxId) {
+    public void onOpen(Session session, @PathParam("clientId") String clientId, @PathParam("paId") String paId) {
         this.session = session;
         this.clientId = clientId;
-        this.boxId = boxId;
+        this.paId = paId;
         if (webSocketMap.containsKey(clientId)) {
             webSocketMap.remove(clientId);
             webSocketMap.put(clientId, this);
@@ -101,7 +101,7 @@
      */
     @OnMessage
     public void onMessage(String message, Session session) throws Exception {
-        logger.info("鐢ㄦ埛娑堟伅:" + boxId + ",瀹㈡埛绔細" + clientId + ",鎶ユ枃:" + message);
+        logger.info("鐢ㄦ埛娑堟伅:" + paId + ",瀹㈡埛绔細" + clientId + ",鎶ユ枃:" + message);
         //鍙互缇ゅ彂娑堟伅
         //娑堟伅淇濆瓨鍒版暟鎹簱銆乺edis
         if (StringUtil.isEmpty(message)) {
@@ -139,17 +139,20 @@
      * 瀹炵幇鏈嶅姟鍣ㄤ富鍔ㄦ帹閫�
      */
     public void sendMessage(String message) throws IOException {
-        this.session.getBasicRemote().sendText(message);
+       // this.session.getBasicRemote().sendText(message);
+        synchronized (this.session) {
+            this.session.getBasicRemote().sendText(message);
+        }
     }
 
 
     /**
      * 鍙戦�佽澶囩洃鎺т俊鎭�
      */
-    public static void sendInfo(String message, String boxId) throws IOException {
-        logger.info("鍙戦�佹秷鎭埌:" + boxId + "锛屾姤鏂�:" + message);
+    public static void sendInfo(String message, String paId) throws IOException {
+        logger.info("鍙戦�佹秷鎭埌:" + paId + "锛屾姤鏂�:" + message);
         for (ParkingAreaWebsocket server : webSocketMap.values()) {
-            if (boxId.equals(server.boxId)) {
+            if (paId.equals(server.paId)) {
                 webSocketMap.get(server.clientId).sendMessage(message);
             }
         }

--
Gitblit v1.8.0