From ecb5b691018c8ff71583833ec9a09d8f2bef81f6 Mon Sep 17 00:00:00 2001
From: 64850858 <648540858@qq.com>
Date: 星期三, 09 六月 2021 09:28:29 +0800
Subject: [PATCH] 增加同步通道超时时间,修复hookIP空字符串时的hookIP的默认值赋值

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java |   69 +++++++++++++++++++++++-----------
 1 files changed, 46 insertions(+), 23 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 0c00b82..4f832ae 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,26 +1,9 @@
 package com.genersoft.iot.vmp.media.zlm;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.genersoft.iot.vmp.common.StreamInfo;
-import com.genersoft.iot.vmp.conf.MediaServerConfig;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
-import org.springframework.util.ConcurrentReferenceHashMap;
-import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
-import java.math.BigInteger;
-import java.text.DecimalFormat;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -30,8 +13,6 @@
  */
 @Component
 public class ZLMHttpHookSubscribe {
-
-    private final static Logger logger = LoggerFactory.getLogger(ZLMHttpHookSubscribe.class);
 
     public enum HookType{
         on_flow_report,
@@ -72,8 +53,6 @@
         for (JSONObject key : eventMap.keySet()) {
             Boolean result = null;
             for (String s : key.keySet()) {
-                String string = hookResponse.getString(s);
-                String string1 = key.getString(s);
                 if (result == null) {
                     result = key.getString(s).equals(hookResponse.getString(s));
                 }else {
@@ -81,10 +60,54 @@
                 }
 
             }
-            if (result) {
+            if (null != result && result) {
                 event = eventMap.get(key);
             }
         }
         return event;
     }
+
+    public void removeSubscribe(HookType type, JSONObject hookResponse) {
+        Map<JSONObject, Event> eventMap = allSubscribes.get(type);
+        if (eventMap == null) {
+            return;
+        }
+        Iterator<Map.Entry<JSONObject, Event>> iterator = eventMap.entrySet().iterator();
+        while (iterator.hasNext()){
+            Map.Entry<JSONObject, Event> next = iterator.next();
+            JSONObject key = next.getKey();
+            Boolean result = null;
+            for (String s : key.keySet()) {
+                if (result == null) {
+                    result = key.getString(s).equals(hookResponse.getString(s));
+                }else {
+                    result = result && key.getString(s).equals(hookResponse.getString(s));
+                }
+
+            }
+            if (null != result && result){
+                iterator.remove();
+            }
+        }
+    }
+
+    /**
+     * 鑾峰彇鏌愪釜绫诲瀷鐨勬墍鏈夌殑璁㈤槄
+     * @param type
+     * @return
+     */
+    public List<ZLMHttpHookSubscribe.Event> getSubscribes(HookType type) {
+        // ZLMHttpHookSubscribe.Event event= null;
+        Map<JSONObject, Event> eventMap = allSubscribes.get(type);
+        if (eventMap == null) {
+            return null;
+        }
+        List<ZLMHttpHookSubscribe.Event> result = new ArrayList<>();
+        for (JSONObject key : eventMap.keySet()) {
+            result.add(eventMap.get(key));
+        }
+        return result;
+    }
+
+
 }

--
Gitblit v1.8.0