From a45fab423bab8e0ce6f1d2a270dfa19a6130193f Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 05 六月 2023 15:01:20 +0800
Subject: [PATCH] 修复国标级联语音对讲

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java |   13 +++++++++----
 1 files changed, 9 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 19ffdc4..8904018 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
@@ -1,6 +1,6 @@
 package com.genersoft.iot.vmp.media.zlm;
 
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
 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;
@@ -38,6 +38,7 @@
             hookSubscribe.setExpires(expiresInstant);
         }
         allSubscribes.computeIfAbsent(hookSubscribe.getHookType(), k -> new ConcurrentHashMap<>()).put(hookSubscribe, event);
+        System.out.println(allSubscribes);
     }
 
     public ZlmHttpHookSubscribe.Event sendNotify(HookType type, JSONObject hookResponse) {
@@ -48,6 +49,7 @@
         }
         for (IHookSubscribe key : eventMap.keySet()) {
             Boolean result = null;
+
             for (String s : key.getContent().keySet()) {
                 if (result == null) {
                     result = key.getContent().getString(s).equals(hookResponse.getString(s));
@@ -98,7 +100,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 +139,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