From a7aaeabc7873a0eafb4a7ecad7f65b018b7a9bc9 Mon Sep 17 00:00:00 2001
From: sean.zhou <sean.zhou@dji.com>
Date: Fri, 24 Feb 2023 19:31:23 +0800
Subject: [PATCH] What's new? 1. Add license for dock. 2. Modify the logic corresponding to the firmware file and device type. 3. Add multiple mqtt clients options. 4. Modify the structure of the interface for obtaining the device list. 5. Fixed some issues.

---
 src/main/java/com/dji/sample/component/websocket/config/WebSocketDefaultHandler.java |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/dji/sample/component/websocket/config/WebSocketDefaultHandler.java b/src/main/java/com/dji/sample/component/websocket/config/WebSocketDefaultHandler.java
index d4c7e7a..11ee861 100644
--- a/src/main/java/com/dji/sample/component/websocket/config/WebSocketDefaultHandler.java
+++ b/src/main/java/com/dji/sample/component/websocket/config/WebSocketDefaultHandler.java
@@ -1,9 +1,7 @@
 package com.dji.sample.component.websocket.config;
 
-import com.dji.sample.component.websocket.model.WebSocketManager;
-import com.dji.sample.component.websocket.service.ISendMessageService;
+import com.dji.sample.component.websocket.service.IWebSocketManageService;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 import org.springframework.web.socket.CloseStatus;
 import org.springframework.web.socket.WebSocketHandler;
@@ -22,20 +20,20 @@
 @Slf4j
 public class WebSocketDefaultHandler extends WebSocketHandlerDecorator {
 
-    @Autowired
-    private ISendMessageService sendMessageService;
+    private IWebSocketManageService webSocketManageService;
 
-    WebSocketDefaultHandler(WebSocketHandler delegate) {
+    WebSocketDefaultHandler(WebSocketHandler delegate, IWebSocketManageService webSocketManageService) {
         super(delegate);
+        this.webSocketManageService = webSocketManageService;
     }
 
     @Override
     public void afterConnectionEstablished(WebSocketSession session) throws Exception {
         Principal principal = session.getPrincipal();
         if (StringUtils.hasText(principal.getName())) {
-            WebSocketManager.put(principal.getName(), new ConcurrentWebSocketSession(session));
+            webSocketManageService.put(principal.getName(), new ConcurrentWebSocketSession(session));
             log.debug("{} is connected. ID: {}. WebSocketSession[current count: {}]",
-                    principal.getName(), session.getId(), WebSocketManager.getConnectedCount());
+                    principal.getName(), session.getId(), webSocketManageService.getConnectedCount());
             return;
         }
         session.close();
@@ -45,9 +43,9 @@
     public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
         Principal principal = session.getPrincipal();
         if (StringUtils.hasText(principal.getName())) {
-            WebSocketManager.remove(principal.getName(), session.getId());
+            webSocketManageService.remove(principal.getName(), session.getId());
             log.debug("{} is disconnected. ID: {}. WebSocketSession[current count: {}]",
-                    principal.getName(), session.getId(), WebSocketManager.getConnectedCount());
+                    principal.getName(), session.getId(), webSocketManageService.getConnectedCount());
         }
 
     }

--
Gitblit v1.9.3