From 8fdd10d1c2723ead1d2c3b232f64f292ba3ce1cc Mon Sep 17 00:00:00 2001
From: che_shuai <che_shuai@massclouds>
Date: 星期一, 24 七月 2023 14:10:46 +0800
Subject: [PATCH] 修复在国标级联选择通道时,如果添加通道到跟平台根目录(即平台本身),无法触发目录变更事件问题.详见 https://github.com/648540858/wvp-GB28181-pro/issues/958

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java
index cf33bb2..cad119a 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java
@@ -4,6 +4,7 @@
 import com.genersoft.iot.vmp.media.zlm.dto.HookType;
 import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
+import com.genersoft.iot.vmp.media.zlm.dto.hook.HookParam;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -26,7 +27,7 @@
 
     @FunctionalInterface
     public interface Event{
-        void response(MediaServerItem mediaServerItem, JSONObject response);
+        void response(MediaServerItem mediaServerItem, HookParam hookParam);
     }
 
     private Map<HookType, Map<IHookSubscribe, ZlmHttpHookSubscribe.Event>> allSubscribes = new ConcurrentHashMap<>();
@@ -98,7 +99,10 @@
 
             if (!CollectionUtils.isEmpty(entriesToRemove)) {
                 for (Map.Entry<IHookSubscribe, ZlmHttpHookSubscribe.Event> entry : entriesToRemove) {
-                    entries.remove(entry);
+                    eventMap.remove(entry.getKey());
+                }
+                if (eventMap.size() == 0) {
+                    allSubscribes.remove(hookSubscribe.getHookType());
                 }
             }
 
@@ -134,9 +138,9 @@
     /**
      * 瀵硅闃呮暟鎹繘琛岃繃鏈熸竻鐞�
      */
-    @Scheduled(cron="0 0/5 * * * ?")   //姣�5鍒嗛挓鎵ц涓�娆�
+//    @Scheduled(cron="0 0/5 * * * ?")   //姣�5鍒嗛挓鎵ц涓�娆�
+    @Scheduled(fixedRate = 2 * 1000)
     public void execute(){
-
         Instant instant = Instant.now().minusMillis(TimeUnit.MINUTES.toMillis(5));
         int total = 0;
         for (HookType hookType : allSubscribes.keySet()) {

--
Gitblit v1.8.0