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/service/impl/WebSocketManageServiceImpl.java | 22 +++++++++-------------
1 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java b/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java
index e2734c0..61e37e1 100644
--- a/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java
+++ b/src/main/java/com/dji/sample/component/websocket/service/impl/WebSocketManageServiceImpl.java
@@ -6,7 +6,6 @@
import com.dji.sample.component.websocket.service.IWebSocketManageService;
import com.dji.sample.manage.model.enums.UserTypeEnum;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@@ -26,10 +25,7 @@
public class WebSocketManageServiceImpl implements IWebSocketManageService {
private static final ConcurrentHashMap<String, ConcurrentWebSocketSession> SESSIONS = new ConcurrentHashMap<>(16);
-
- @Autowired
- private RedisOpsUtils redisOps;
-
+
@Override
public void put(String key, ConcurrentWebSocketSession val) {
String[] name = key.split("/");
@@ -40,11 +36,11 @@
String sessionId = val.getId();
String workspaceKey = RedisConst.WEBSOCKET_PREFIX + name[0];
String userTypeKey = RedisConst.WEBSOCKET_PREFIX + UserTypeEnum.find(Integer.parseInt(name[1])).getDesc();
- redisOps.hashSet(workspaceKey, sessionId, name[2]);
- redisOps.hashSet(userTypeKey, sessionId, name[2]);
+ RedisOpsUtils.hashSet(workspaceKey, sessionId, name[2]);
+ RedisOpsUtils.hashSet(userTypeKey, sessionId, name[2]);
SESSIONS.put(sessionId, val);
- redisOps.expireKey(workspaceKey, RedisConst.WEBSOCKET_ALIVE_SECOND);
- redisOps.expireKey(userTypeKey, RedisConst.WEBSOCKET_ALIVE_SECOND);
+ RedisOpsUtils.expireKey(workspaceKey, RedisConst.WEBSOCKET_ALIVE_SECOND);
+ RedisOpsUtils.expireKey(userTypeKey, RedisConst.WEBSOCKET_ALIVE_SECOND);
}
@Override
@@ -54,8 +50,8 @@
log.debug("The key is out of format. [{workspaceId}/{userType}/{userId}]");
return;
}
- redisOps.hashDel(RedisConst.WEBSOCKET_PREFIX + name[0], new String[] {sessionId});
- redisOps.hashDel(RedisConst.WEBSOCKET_PREFIX + UserTypeEnum.find(Integer.parseInt(name[1])), new String[] {sessionId});
+ RedisOpsUtils.hashDel(RedisConst.WEBSOCKET_PREFIX + name[0], new String[] {sessionId});
+ RedisOpsUtils.hashDel(RedisConst.WEBSOCKET_PREFIX + UserTypeEnum.find(Integer.parseInt(name[1])).getDesc(), new String[] {sessionId});
SESSIONS.remove(sessionId);
}
@@ -66,7 +62,7 @@
}
String key = RedisConst.WEBSOCKET_PREFIX + workspaceId;
- return redisOps.hashKeys(key)
+ return RedisOpsUtils.hashKeys(key)
.stream()
.map(SESSIONS::get)
.filter(Objects::nonNull)
@@ -76,7 +72,7 @@
@Override
public Collection<ConcurrentWebSocketSession> getValueWithWorkspaceAndUserType(String workspaceId, Integer userType) {
String key = RedisConst.WEBSOCKET_PREFIX + UserTypeEnum.find(userType).getDesc();
- return redisOps.hashKeys(key)
+ return RedisOpsUtils.hashKeys(key)
.stream()
.map(SESSIONS::get)
.filter(Objects::nonNull)
--
Gitblit v1.9.3