From 21a96ad20fd75e55d03c00af8df8adb039f0c77a Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 20 六月 2023 12:51:06 +0800
Subject: [PATCH] 修复通道刷新

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java |   38 ++++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
index 3d5c294..2175a45 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
@@ -1,6 +1,5 @@
 package com.genersoft.iot.vmp.gb28181.transmit.callback;
 
-import com.alibaba.fastjson2.JSON;
 import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
@@ -40,17 +39,21 @@
 
 	public static final String CALLBACK_CMD_DOWNLOAD = "CALLBACK_DOWNLOAD";
 
+	public static final String CALLBACK_CMD_PROXY = "CALLBACK_PROXY";
+
 	public static final String CALLBACK_CMD_STOP = "CALLBACK_STOP";
 
 	public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL";
 
-	public static final String CALLBACK_CMD_MOBILEPOSITION = "CALLBACK_MOBILEPOSITION";
+	public static final String CALLBACK_CMD_MOBILE_POSITION = "CALLBACK_CMD_MOBILE_POSITION";
 
 	public static final String CALLBACK_CMD_PRESETQUERY = "CALLBACK_PRESETQUERY";
 
 	public static final String CALLBACK_CMD_ALARM = "CALLBACK_ALARM";
 
 	public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST";
+
+	public static final String CALLBACK_CMD_SNAP= "CALLBACK_SNAP";
 
 	private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>();
 
@@ -130,23 +133,26 @@
 		if (deferredResultMap == null) {
 			return;
 		}
-		Set<String> ids = deferredResultMap.keySet();
-		for (String id : ids) {
-			DeferredResultEx result = deferredResultMap.get(id);
-			if (result == null) {
+		synchronized (this) {
+			deferredResultMap = map.get(msg.getKey());
+			if (deferredResultMap == null) {
 				return;
 			}
-			if (result.getFilter() != null) {
-				Object handler = result.getFilter().handler(msg.getData());
-				System.out.println(JSON.toJSONString(handler));
-				result.getDeferredResult().setResult(handler);
-			}else {
-				result.getDeferredResult().setResult(msg.getData());
+			Set<String> ids = deferredResultMap.keySet();
+			for (String id : ids) {
+				DeferredResultEx result = deferredResultMap.get(id);
+				if (result == null) {
+					return;
+				}
+				if (result.getFilter() != null) {
+					Object handler = result.getFilter().handler(msg.getData());
+					result.getDeferredResult().setResult(handler);
+				}else {
+					result.getDeferredResult().setResult(msg.getData());
+				}
+
 			}
-
+			map.remove(msg.getKey());
 		}
-		map.remove(msg.getKey());
 	}
-
-
 }

--
Gitblit v1.8.0